Skip to content

Commit

Permalink
fix: ensure NCMAPSS scaling range is tuple (#61)
Browse files Browse the repository at this point in the history
* fix: ensure scaling range is a tuple

* fix: scaling range type hint
  • Loading branch information
tilman151 authored May 2, 2024
1 parent 55e59f9 commit 6c870d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rul_datasets/reader/ncmapss.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def __init__(
truncate_degraded_only: bool = False,
resolution_seconds: int = 1,
padding_value: float = 0.0,
scaling_range: Optional[Tuple[int, int]] = (0, 1),
scaling_range: Tuple[int, int] = (0, 1),
) -> None:
"""
Create a new reader for the New C-MAPSS dataset. The maximum RUL value is set
Expand Down Expand Up @@ -173,7 +173,7 @@ def __init__(
self.run_split_dist = run_split_dist or self._get_default_split(self.fd)
self.resolution_seconds = resolution_seconds
self.padding_value = padding_value
self.scaling_range = scaling_range
self.scaling_range = tuple(scaling_range)

if self.resolution_seconds > 1 and window_size is None:
warnings.warn(
Expand Down
8 changes: 8 additions & 0 deletions tests/reader/test_ncmapss.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,11 @@ def test_feature_select(prepared_ncmapss):
features, _ = reader.load_complete_split("dev", "dev")

assert features[0].shape[2] == 10


@pytest.mark.parametrize("scaling_range", [(0, 1), [0, 1]])
def test_scaling_range_is_tuple(scaling_range):
reader = NCmapssReader(1, scaling_range=scaling_range)

assert isinstance(reader.scaling_range, tuple)
assert reader.scaling_range == (0, 1)

0 comments on commit 6c870d4

Please sign in to comment.