Skip to content

Commit

Permalink
remove util function for checking unique values
Browse files Browse the repository at this point in the history
  • Loading branch information
SarahAlidoost committed Apr 12, 2024
1 parent 9dc7804 commit 0666878
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 38 deletions.
19 changes: 0 additions & 19 deletions stmtools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,3 @@ def monotonic_coords(ds, dim: str):
ds[dim].to_index().is_monotonic_increasing
or ds[dim].to_index().is_monotonic_decreasing
)


def unique_coords(ds, dim: str ):
"""Check if the dataset has unique coordinates in the given dimension.
Parameters
----------
ds : xarray.Dataset
Dataset to check.
dim : str
Dimension to check.
Returns
-------
bool
True if the dataset has unique coordinates, False otherwise.
"""
return bool(ds[dim].to_index().is_unique)
19 changes: 0 additions & 19 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,22 +157,3 @@ def test_non_monotonic_coords_time(self, stmat):
stmat["time"].values[0] = '2022-01-02T00:00:00.000000000'
stmat["time"].values[1] = '2022-01-01T00:00:00.000000000'
assert not utils.monotonic_coords(stmat, "time")


class TestUniqueCoords:
def test_unique_coords(self, stmat):
assert utils.unique_coords(stmat, "lon")
assert utils.unique_coords(stmat, "lat")
assert utils.unique_coords(stmat, "time")

def test_non_unique_coords_lon(self, stmat):
stmat["lon"][0] = 1
assert not utils.unique_coords(stmat, "lon")

def test_non_unique_coords_lat(self, stmat):
stmat["lat"][0] = 1
assert not utils.unique_coords(stmat, "lat")

def test_non_unique_coords_time(self, stmat):
stmat["time"].values[0] = '2021-01-03T00:00:00.000000000'
assert not utils.unique_coords(stmat, "time")

0 comments on commit 0666878

Please sign in to comment.