Skip to content

Commit

Permalink
update tests for minimum_weight parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
pochedls authored and tomvothecoder committed Sep 5, 2024
1 parent a0d0a28 commit ad118ed
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tests/test_spatial.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,16 @@ def test_raises_error_if_weights_lat_and_lon_dims_dont_align_with_data_var_dims(
with pytest.raises(ValueError):
self.ds.spatial.average("ts", axis=["X", "Y"], weights=weights)

def test_raises_error_if_required_weight_not_between_zero_and_one(
def test_raises_error_if_minimum_weight_not_between_zero_and_one(
self,
):
# ensure error if required_weight less than zero
# ensure error if minimum_weight less than zero
with pytest.raises(ValueError):
self.ds.spatial.average("ts", axis=["X", "Y"], required_weight=-0.01)
self.ds.spatial.average("ts", axis=["X", "Y"], minimum_weight=-0.01)

# ensure error if required_weight greater than 1
# ensure error if minimum_weight greater than 1
with pytest.raises(ValueError):
self.ds.spatial.average("ts", axis=["X", "Y"], required_weight=1.01)
self.ds.spatial.average("ts", axis=["X", "Y"], minimum_weight=1.01)

def test_spatial_average_for_lat_region_and_keep_weights(self):
ds = self.ds.copy()
Expand Down Expand Up @@ -265,7 +265,7 @@ def test_spatial_average_for_lat_and_lon_region_and_keep_weights(self):

xr.testing.assert_allclose(result, expected)

def test_spatial_average_with_required_weight(self):
def test_spatial_average_with_minimum_weight(self):
ds = self.ds.copy()

# insert a nan
Expand All @@ -276,7 +276,7 @@ def test_spatial_average_with_required_weight(self):
axis=["X", "Y"],
lat_bounds=(-5.0, 5),
lon_bounds=(-170, -120.1),
required_weight=1.0,
minimum_weight=1.0,
)

expected = self.ds.copy()
Expand All @@ -288,15 +288,15 @@ def test_spatial_average_with_required_weight(self):

xr.testing.assert_allclose(result, expected)

def test_spatial_average_with_required_weight_as_None(self):
def test_spatial_average_with_minimum_weight_as_None(self):
ds = self.ds.copy()

result = ds.spatial.average(
"ts",
axis=["X", "Y"],
lat_bounds=(-5.0, 5),
lon_bounds=(-170, -120.1),
required_weight=None,
minimum_weight=None,
)

expected = self.ds.copy()
Expand Down

0 comments on commit ad118ed

Please sign in to comment.