diff --git a/tests/test_routines.py b/tests/test_routines.py index df53695..17e1226 100644 --- a/tests/test_routines.py +++ b/tests/test_routines.py @@ -1,6 +1,6 @@ import numpy as np import pytest -from xdas.core.routines import Bag, SplitError +from xdas.core.routines import Bag, CompatibilityError from xdas.core.dataarray import DataArray from xdas.core.coordinates import Coordinates @@ -49,7 +49,7 @@ def test_bag_append_incompatible_dims(self): da2 = DataArray(np.random.rand(10, 5), dims=("space", "time")) bag = Bag(dim="time") bag.append(da1) - with pytest.raises(SplitError): + with pytest.raises(CompatibilityError): bag.append(da2) def test_bag_append_incompatible_shape(self): @@ -57,7 +57,7 @@ def test_bag_append_incompatible_shape(self): da2 = DataArray(np.random.rand(10, 6), dims=("time", "space")) bag = Bag(dim="time") bag.append(da1) - with pytest.raises(SplitError): + with pytest.raises(CompatibilityError): bag.append(da2) def test_bag_append_incompatible_dtype(self): @@ -65,7 +65,7 @@ def test_bag_append_incompatible_dtype(self): da2 = DataArray(np.random.randint(0, 10, size=(10, 5)), dims=("time", "space")) bag = Bag(dim="time") bag.append(da1) - with pytest.raises(SplitError): + with pytest.raises(CompatibilityError): bag.append(da2) def test_bag_append_incompatible_coords(self): @@ -81,7 +81,7 @@ def test_bag_append_incompatible_coords(self): ) bag = Bag(dim="time") bag.append(da1) - with pytest.raises(SplitError): + with pytest.raises(CompatibilityError): bag.append(da2) def test_bag_append_incompatible_sampling_interval(self): @@ -97,5 +97,5 @@ def test_bag_append_incompatible_sampling_interval(self): ) bag = Bag(dim="time") bag.append(da1) - with pytest.raises(SplitError): + with pytest.raises(CompatibilityError): bag.append(da2) diff --git a/xdas/core/routines.py b/xdas/core/routines.py index 861f792..cc0f1e4 100644 --- a/xdas/core/routines.py +++ b/xdas/core/routines.py @@ -520,7 +520,7 @@ def combine_by_coords( for da in objs: try: bag.append(da) - except SplitError: + except CompatibilityError: bags.append(bag) bag = Bag(dim) bag.append(da) @@ -537,7 +537,7 @@ def combine_by_coords( return collection -class SplitError(Exception): +class CompatibilityError(Exception): """Custom exception to signal required splitting.""" def __init__(self, message): @@ -582,16 +582,16 @@ def append(self, da): def check_dims(self, da): if not self.dims == da.dims: - raise SplitError("dimensions are not compatible") + raise CompatibilityError("dimensions are not compatible") def check_shape(self, da): subshape = tuple(size for dim, size in da.sizes.items() if not dim == self.dim) if not self.subshape == subshape: - raise SplitError("shapes are not compatible") + raise CompatibilityError("shapes are not compatible") def check_dtype(self, da): if not self.dtype == da.dtype: - raise SplitError("data types are not compatible") + raise CompatibilityError("data types are not compatible") def check_coords(self, da): subcoords = ( @@ -600,7 +600,7 @@ def check_coords(self, da): else da.coords.drop_coords(self.dim) ) if not self.subcoords.equals(subcoords): - raise SplitError("coordinates are not compatible") + raise CompatibilityError("coordinates are not compatible") def check_sampling_interval(self, da): if self.delta is None: @@ -608,7 +608,7 @@ def check_sampling_interval(self, da): else: delta = get_sampling_interval(da, self.dim) if not np.isclose(delta, self.delta): - raise SplitError("sampling intervals are not compatible") + raise CompatibilityError("sampling intervals are not compatible") def concatenate(objs, dim="first", tolerance=None, virtual=None, verbose=None):