Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdudfield committed Jan 2, 2025
1 parent 6150c46 commit feba5d1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
17 changes: 3 additions & 14 deletions src/nwp_consumer/internal/entities/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ class NWPDimensionCoordinateMap:
Will be truncated to 4 decimal places, and ordered as 90 -> -90.
"""
longitude: list[float] | None = None
"""The longitude coordinates of the forecast grid in degrees. """
large_chunk_divider_size: int = 8
""" For large dimensions, the amount of steps in each chunk
"""The longitude coordinates of the forecast grid in degrees.

Check failure on line 93 in src/nwp_consumer/internal/entities/coordinates.py

View workflow job for this annotation

GitHub Actions / lint-typecheck

Ruff (W291)

src/nwp_consumer/internal/entities/coordinates.py:93:66: W291 Trailing whitespace
Will be truncated to 4 decimal places, and ordered as -180 -> 180.
"""
Expand All @@ -119,15 +117,7 @@ def dims(self) -> list[str]:
index value list.
"""
return [f.name for f in dataclasses.fields(self) if
getattr(self, f.name) is not None and f.name != "large_chunk_divider_size"]

def set_large_chunk_divider_size(self, large_chunk_divider_size: int) \
-> "NWPDimensionCoordinateMap":
"""Set the large chunk divider size for the map.
This is the number of steps in each chunk for large dimensions.
"""
return dataclasses.replace(self, large_chunk_divider_size=large_chunk_divider_size)
getattr(self, f.name) is not None]

@property
def shapemap(self) -> dict[str, int]:
Expand Down Expand Up @@ -420,8 +410,7 @@ def default_chunking(self) -> dict[str, int]:
"init_time": 1,
"step": 1,
} | {
dim: len(getattr(self, dim)) // self.large_chunk_divider_size
if len(getattr(self, dim)) > self.large_chunk_divider_size else 1
dim: len(getattr(self, dim)) // 8 if len(getattr(self, dim)) > 8 else 1
for dim in self.dims
if dim not in ["init_time", "step"]
}
Expand Down
5 changes: 0 additions & 5 deletions src/nwp_consumer/internal/entities/modelmetadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ def with_region(self, region: str) -> "ModelMetadata":
log.warning(f"Unknown region '{region}', not cropping expected coordinates.")
return self

def set_large_chunk_divider_size(self, large_chunk_divider_size: int) -> "ModelMetadata":
"""Set the large chunk divider."""
self.expected_coordinates.large_chunk_divider_size = large_chunk_divider_size
return self


class Models:
"""Namespace containing known models."""
Expand Down

0 comments on commit feba5d1

Please sign in to comment.