Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
JBorrow committed Sep 19, 2024
1 parent bcc86b9 commit 62ae2b3
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions swiftsimio/masks.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class SWIFTMask(object):
Main masking object. This can have masks for any present particle field in it.
Pass in the SWIFTMetadata.
"""

group_mapping: dict | None = None
group_size_mapping: dict | None = None

Expand Down Expand Up @@ -91,7 +91,7 @@ def _generate_mapping_dictionary(self) -> dict[str, str]:
}

return self.group_mapping

def _generate_size_mapping_dictionary(self) -> dict[str, str]:
"""
Creates cross-links between 'group names' and their underlying cell metadata
Expand All @@ -105,16 +105,18 @@ def _generate_size_mapping_dictionary(self) -> dict[str, str]:
# Each and every particle type has its own cell counts, offsets,
# and hence masks.
self.group_size_mapping = {
f"{group}_size": f"_{group}_size" for group in self.metadata.present_group_names
f"{group}_size": f"_{group}_size"
for group in self.metadata.present_group_names
}
else:
# We actually only have _one_ mask!
self.group_size_mapping = {
f"{group}_size": "_shared_size" for group in self.metadata.present_group_names
f"{group}_size": "_shared_size"
for group in self.metadata.present_group_names
}

return self.group_size_mapping

def _generate_update_list(self) -> list[str]:
"""
Gets a list of internal mask variables that need to be updated when
Expand All @@ -134,15 +136,17 @@ def __getattr__(self, name):
Overloads the getattr method to allow for direct access to the masks
for each particle type.
"""
mappings = {**self._generate_mapping_dictionary(), **self._generate_size_mapping_dictionary()}
mappings = {
**self._generate_mapping_dictionary(),
**self._generate_size_mapping_dictionary(),
}

underlying_name = mappings.get(name, None)

if underlying_name is not None:
return getattr(self, underlying_name)

raise AttributeError(f"Attribute {name} not found in SWIFTMask")


def _generate_empty_masks(self):
"""
Expand Down

0 comments on commit 62ae2b3

Please sign in to comment.