Skip to content

Commit

Permalink
Change 'dataset' to 'data' in error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
mgunyho committed Sep 4, 2023
1 parent 7fa5026 commit fdcad9a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
20 changes: 10 additions & 10 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2629,7 +2629,7 @@ def chunk(
bad_dims = chunks.keys() - self.dims.keys()
if bad_dims:
raise ValueError(
f"chunks keys {tuple(bad_dims)} not found in dataset dimensions {tuple(self.dims)}"
f"chunks keys {tuple(bad_dims)} not found in data dimensions {tuple(self.dims)}"
)

chunkmanager = guess_chunkmanager(chunked_array_type)
Expand Down Expand Up @@ -5442,7 +5442,7 @@ def unstack(
missing_dims = set(dims) - set(self.dims)
if missing_dims:
raise ValueError(
f"Dimensions {tuple(missing_dims)} not found in dataset dimensions {tuple(self.dims)}"
f"Dimensions {tuple(missing_dims)} not found in data dimensions {tuple(self.dims)}"
)

# each specified dimension must have exactly one multi-index
Expand Down Expand Up @@ -6078,7 +6078,7 @@ def drop_dims(
missing_dims = drop_dims - set(self.dims)
if missing_dims:
raise ValueError(
f"Dimensions {tuple(missing_dims)} not found in dataset dimensions {tuple(self.dims)}"
f"Dimensions {tuple(missing_dims)} not found in data dimensions {tuple(self.dims)}"
)

drop_vars = {k for k, v in self._variables.items() if set(v.dims) & drop_dims}
Expand Down Expand Up @@ -6239,7 +6239,7 @@ def dropna(

if dim not in self.dims:
raise ValueError(
f"Dimension {dim!r} not found in dataset dimensions {tuple(self.dims)}"
f"Dimension {dim!r} not found in data dimensions {tuple(self.dims)}"
)

if subset is None:
Expand Down Expand Up @@ -6724,7 +6724,7 @@ def reduce(
missing_dimensions = tuple(d for d in dims if d not in self.dims)
if missing_dimensions:
raise ValueError(
f"Dimensions {missing_dimensions} not found in dataset dimensions {tuple(self.dims)}"
f"Dimensions {missing_dimensions} not found in data dimensions {tuple(self.dims)}"
)

if keep_attrs is None:
Expand Down Expand Up @@ -7710,7 +7710,7 @@ def shift(
invalid = tuple(k for k in shifts if k not in self.dims)
if invalid:
raise ValueError(
f"Dimensions {invalid} not found in dataset dimensions {tuple(self.dims)}"
f"Dimensions {invalid} not found in data dimensions {tuple(self.dims)}"
)

variables = {}
Expand Down Expand Up @@ -7789,7 +7789,7 @@ def roll(
invalid = [k for k in shifts if k not in self.dims]
if invalid:
raise ValueError(
f"Dimensions {invalid} not found in dataset dimensions {tuple(self.dims)}"
f"Dimensions {invalid} not found in data dimensions {tuple(self.dims)}"
)

unrolled_vars: tuple[Hashable, ...]
Expand Down Expand Up @@ -8042,7 +8042,7 @@ def quantile(
invalid_dims = set(dims) - set(self.dims)
if invalid_dims:
raise ValueError(
f"Dimensions {tuple(invalid_dims)} not found in dataset dimensions {tuple(self.dims)}"
f"Dimensions {tuple(invalid_dims)} not found in data dimensions {tuple(self.dims)}"
)

q = np.asarray(q, dtype=np.float64)
Expand Down Expand Up @@ -8120,7 +8120,7 @@ def rank(

if dim not in self.dims:
raise ValueError(
f"Dimension {dim!r} not found in dataset dimensions {tuple(self.dims)}"
f"Dimension {dim!r} not found in data dimensions {tuple(self.dims)}"
)

variables = {}
Expand Down Expand Up @@ -9782,7 +9782,7 @@ def drop_duplicates(
missing_dims = set(dims) - set(self.dims)
if missing_dims:
raise ValueError(
f"Dimensions {tuple(missing_dims)} not found in dataset dimensions {tuple(self.dims)}"
f"Dimensions {tuple(missing_dims)} not found in data dimensions {tuple(self.dims)}"
)

indexes = {dim: ~self.get_index(dim).duplicated(keep=keep) for dim in dims}
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -6962,7 +6962,7 @@ def test_drop_duplicates_1d(self, keep) -> None:
with pytest.raises(
ValueError,
match=re.escape(
"Dimensions ('space',) not found in dataset dimensions ('time',)"
"Dimensions ('space',) not found in data dimensions ('time',)"
),
):
da.drop_duplicates("space", keep=keep)
Expand Down
16 changes: 7 additions & 9 deletions xarray/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ def get_dask_names(ds):
with pytest.raises(
ValueError,
match=re.escape(
"chunks keys ('foo',) not found in dataset dimensions ('dim2', 'dim3', 'time', 'dim1')"
"chunks keys ('foo',) not found in data dimensions ('dim2', 'dim3', 'time', 'dim1')"
),
):
data.chunk({"foo": 10})
Expand Down Expand Up @@ -3682,9 +3682,7 @@ def test_unstack_errors(self) -> None:
ds = Dataset({"x": [1, 2, 3]})
with pytest.raises(
ValueError,
match=re.escape(
"Dimensions ('foo',) not found in dataset dimensions ('x',)"
),
match=re.escape("Dimensions ('foo',) not found in data dimensions ('x',)"),
):
ds.unstack("foo")
with pytest.raises(ValueError, match=r".*do not have exactly one multi-index"):
Expand Down Expand Up @@ -4977,7 +4975,7 @@ def test_dropna(self) -> None:

with pytest.raises(
ValueError,
match=r"'foo' not found in dataset dimensions \('a', 'b'\)",
match=r"'foo' not found in data dimensions \('a', 'b'\)",
):
ds.dropna("foo")
with pytest.raises(ValueError, match=r"invalid how"):
Expand Down Expand Up @@ -5298,7 +5296,7 @@ def test_reduce_bad_dim(self) -> None:
data = create_test_data()
with pytest.raises(
ValueError,
match=r"Dimensions \('bad_dim',\) not found in dataset dimensions",
match=r"Dimensions \('bad_dim',\) not found in data dimensions",
):
data.mean(dim="bad_dim")

Expand Down Expand Up @@ -5327,7 +5325,7 @@ def test_reduce_cumsum_test_dims(self, reduct, expected, func) -> None:
data = create_test_data()
with pytest.raises(
ValueError,
match=r"Dimensions \('bad_dim',\) not found in dataset dimensions",
match=r"Dimensions \('bad_dim',\) not found in data dimensions",
):
getattr(data, func)(dim="bad_dim")

Expand Down Expand Up @@ -5579,7 +5577,7 @@ def test_rank(self) -> None:
with pytest.raises(
ValueError,
match=re.escape(
"Dimension 'invalid_dim' not found in dataset dimensions ('dim3', 'dim1')"
"Dimension 'invalid_dim' not found in data dimensions ('dim3', 'dim1')"
),
):
x.rank("invalid_dim")
Expand Down Expand Up @@ -7117,7 +7115,7 @@ def test_drop_duplicates_1d(self, keep) -> None:
with pytest.raises(
ValueError,
match=re.escape(
"Dimensions ('space',) not found in dataset dimensions ('time',)"
"Dimensions ('space',) not found in data dimensions ('time',)"
),
):
ds.drop_duplicates("space", keep=keep)
Expand Down

0 comments on commit fdcad9a

Please sign in to comment.