diff --git a/cf_xarray/accessor.py b/cf_xarray/accessor.py index 21feb6ff..602801c3 100644 --- a/cf_xarray/accessor.py +++ b/cf_xarray/accessor.py @@ -796,7 +796,6 @@ def _guess_bounds(da, dim=None, out_dim="bounds"): f"If dim is None, variable {da.name} must be 1D or 2D. Received {da.ndim}D variable instead." ) dim = da.dims - if not isinstance(dim, str): if len(dim) > 2: raise NotImplementedError( diff --git a/cf_xarray/geometry.py b/cf_xarray/geometry.py index 6e4f1090..442e632b 100644 --- a/cf_xarray/geometry.py +++ b/cf_xarray/geometry.py @@ -586,7 +586,11 @@ def points_to_cf( coord = None pts_ = pts - x, y, node_count, crdX, crdY = [], [], [], [], [] + x: list[np.ndarray] = [] + y: list[np.ndarray] = [] + node_count: list[int] = [] + crdX: list[float] = [] + crdY: list[float] = [] for pt in pts_: if isinstance(pt, MultiPoint): xy = np.concatenate([p.coords for p in pt.geoms]) diff --git a/cf_xarray/helpers.py b/cf_xarray/helpers.py index 1053a55b..747f111c 100644 --- a/cf_xarray/helpers.py +++ b/cf_xarray/helpers.py @@ -34,7 +34,7 @@ def _guess_bounds_1d(da, dim): result = xr.concat([first, bounds], dim=dim).transpose(..., "bounds") if ADDED_INDEX: result = result.drop_vars(dim) - return result + return result.drop_attrs(deep=False) def _guess_bounds_2d(da, dims): diff --git a/cf_xarray/tests/test_accessor.py b/cf_xarray/tests/test_accessor.py index 3b65fbc6..58a811bf 100644 --- a/cf_xarray/tests/test_accessor.py +++ b/cf_xarray/tests/test_accessor.py @@ -832,6 +832,9 @@ def test_add_bounds(dims): assert_allclose( added[name].reset_coords(drop=True), expected[dim].transpose(..., "bounds") ) + if dim == "lat": + # The CF axes shouldn't have changed + assert added.cf.axes["Y"] == ["lat"] _check_unchanged(original, ds) diff --git a/cf_xarray/units.py b/cf_xarray/units.py index e1d553e8..7f0fb281 100644 --- a/cf_xarray/units.py +++ b/cf_xarray/units.py @@ -60,7 +60,7 @@ def short_formatter(unit, registry, **options): # Reused with modification from MetPy under the terms of the BSD 3-Clause License. # Copyright (c) 2015,2017,2019 MetPy Developers. # Create registry, with preprocessors for UDUNITS-style powers (m2 s-2) and percent signs -units = pint.UnitRegistry( +units: pint.UnitRegistry = pint.UnitRegistry( autoconvert_offset_to_baseunit=True, preprocessors=[ functools.partial( diff --git a/pyproject.toml b/pyproject.toml index a496e8b1..ad90d566 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -107,7 +107,6 @@ docstring-code-format = true [tool.pytest] -python_files = "test_*.py" testpaths = ["cf_xarray/tests"] [tool.rstcheck]