Skip to content

Commit 75f2dc6

Browse files
authored
Dont preserve attributes when creating bounds (#608)
* Dont preserve attrs when creating bounds * Explicit drop attrs where needed * revert unwanted removal * fix mypy issues * Remove pytest config that is unnecessary and changed in pytest 9 - remove pin
1 parent 26c0c69 commit 75f2dc6

File tree

6 files changed

+10
-5
lines changed

6 files changed

+10
-5
lines changed

cf_xarray/accessor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,6 @@ def _guess_bounds(da, dim=None, out_dim="bounds"):
796796
f"If dim is None, variable {da.name} must be 1D or 2D. Received {da.ndim}D variable instead."
797797
)
798798
dim = da.dims
799-
800799
if not isinstance(dim, str):
801800
if len(dim) > 2:
802801
raise NotImplementedError(

cf_xarray/geometry.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,11 @@ def points_to_cf(
586586
coord = None
587587
pts_ = pts
588588

589-
x, y, node_count, crdX, crdY = [], [], [], [], []
589+
x: list[np.ndarray] = []
590+
y: list[np.ndarray] = []
591+
node_count: list[int] = []
592+
crdX: list[float] = []
593+
crdY: list[float] = []
590594
for pt in pts_:
591595
if isinstance(pt, MultiPoint):
592596
xy = np.concatenate([p.coords for p in pt.geoms])

cf_xarray/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def _guess_bounds_1d(da, dim):
3434
result = xr.concat([first, bounds], dim=dim).transpose(..., "bounds")
3535
if ADDED_INDEX:
3636
result = result.drop_vars(dim)
37-
return result
37+
return result.drop_attrs(deep=False)
3838

3939

4040
def _guess_bounds_2d(da, dims):

cf_xarray/tests/test_accessor.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,9 @@ def test_add_bounds(dims):
832832
assert_allclose(
833833
added[name].reset_coords(drop=True), expected[dim].transpose(..., "bounds")
834834
)
835+
if dim == "lat":
836+
# The CF axes shouldn't have changed
837+
assert added.cf.axes["Y"] == ["lat"]
835838

836839
_check_unchanged(original, ds)
837840

cf_xarray/units.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def short_formatter(unit, registry, **options):
6060
# Reused with modification from MetPy under the terms of the BSD 3-Clause License.
6161
# Copyright (c) 2015,2017,2019 MetPy Developers.
6262
# Create registry, with preprocessors for UDUNITS-style powers (m2 s-2) and percent signs
63-
units = pint.UnitRegistry(
63+
units: pint.UnitRegistry = pint.UnitRegistry(
6464
autoconvert_offset_to_baseunit=True,
6565
preprocessors=[
6666
functools.partial(

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ docstring-code-format = true
107107

108108

109109
[tool.pytest]
110-
python_files = "test_*.py"
111110
testpaths = ["cf_xarray/tests"]
112111

113112
[tool.rstcheck]

0 commit comments

Comments
 (0)