Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ ci:
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: 'v0.0.237'
rev: 'v0.0.260'
hooks:
- id: ruff
args: ["--fix"]

- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.3.0
hooks:
- id: black

- repo: https://github.com/rstcheck/rstcheck
rev: v6.1.1
rev: v6.1.2
hooks:
- id: rstcheck
additional_dependencies: [sphinx, tomli]
Expand All @@ -30,7 +30,7 @@ repos:
- mdformat-myst

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.6.1
rev: 1.7.0
hooks:
- id: nbqa-black
- id: nbqa-ruff
Expand Down Expand Up @@ -61,6 +61,6 @@ repos:
- id: validate-cff

- repo: https://github.com/abravalheri/validate-pyproject
rev: main
rev: v0.12.2
hooks:
- id: validate-pyproject
4 changes: 0 additions & 4 deletions cf_xarray/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ def apply_mapper(
default = [] if default is None else list(always_iterable(default))

def _apply_single_mapper(mapper):

try:
results = mapper(obj, key)
except (KeyError, ValueError) as e:
Expand Down Expand Up @@ -1218,7 +1217,6 @@ def curvefit(
param_names: Sequence[str] | None = None,
kwargs: dict[str, Any] | None = None,
):

if coords is not None:
if isinstance(coords, (Hashable, DataArray)):
coords_iter: Iterable[Hashable | DataArray] = [coords]
Expand Down Expand Up @@ -2053,7 +2051,6 @@ def add_canonical_attributes(
ds = self._maybe_to_dataset().copy(deep=False)
attrs_to_print: dict = {}
for std_name, var_names in ds.cf.standard_names.items():

# Loop over variable names
for var_name in var_names:
old_attrs = ds[var_name].attrs
Expand All @@ -2067,7 +2064,6 @@ def add_canonical_attributes(
and key not in skip_
and (override or key not in old_attrs)
):

# Don't add units to time variables (e.g., datetime64, ...)
if key == "units" and _is_datetime_like(ds[var_name]):
continue
Expand Down
1 change: 0 additions & 1 deletion cf_xarray/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def make_text_section(
default_keys=None,
rich: bool = False,
):

from .accessor import sort_maybe_hashable

if dims is None:
Expand Down
14 changes: 0 additions & 14 deletions cf_xarray/tests/test_accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def assert_dicts_identical(dict1, dict2):


def test_repr() -> None:

assert "air_temperature: [(1, 2, 3)]" in ds_with_tuple.cf.__repr__()

# Dataset.
Expand Down Expand Up @@ -454,7 +453,6 @@ def test_rename_like() -> None:
),
)
def test_wrapped_classes(obj, attr, xrkwargs, cfkwargs):

if attr in ("rolling", "coarsen"):
# TODO: xarray bug, rolling and coarsen don't accept ellipsis
args = ()
Expand Down Expand Up @@ -522,7 +520,6 @@ def test_pos_args_methods() -> None:


def test_preserve_unused_keys() -> None:

ds = airds.copy(deep=False)
ds.time.attrs.clear()
actual = ds.cf.sel(X=260, Y=40, time=airds.time[:2], method="nearest")
Expand All @@ -531,7 +528,6 @@ def test_preserve_unused_keys() -> None:


def test_kwargs_expand_key_to_multiple_keys() -> None:

actual = multiple.cf.isel(X=5, Y=3)
expected = multiple.isel(x1=5, y1=3, x2=5, y2=3)
assert_identical(actual, expected)
Expand Down Expand Up @@ -571,7 +567,6 @@ def test_args_methods(obj):


def test_dataarray_getitem() -> None:

air = airds.air.copy(deep=False)
air.name = None

Expand All @@ -586,7 +581,6 @@ def test_dataarray_getitem() -> None:


def test_dataarray_plot() -> None:

obj = airds.air.copy(deep=False)

rv = obj.isel(time=1).transpose("lon", "lat").cf.plot()
Expand Down Expand Up @@ -1375,7 +1369,6 @@ def test_standard_name_mapper() -> None:
@pytest.mark.parametrize("obj", objects)
@pytest.mark.parametrize("attr", ["drop_vars", "set_coords"])
def test_drop_vars_and_set_coords(obj, attr):

# DataArray object has no attribute set_coords
if not isinstance(obj, Dataset) and attr == "set_coords":
return
Expand All @@ -1398,7 +1391,6 @@ def test_drop_vars_and_set_coords(obj, attr):

@pytest.mark.parametrize("obj", objects)
def test_drop_sel_and_reset_coords(obj):

# Axis
assert_identical(obj.drop_sel(lat=75), obj.cf.drop_sel(Y=75))
# Coordinate
Expand All @@ -1415,7 +1407,6 @@ def test_drop_sel_and_reset_coords(obj):

@pytest.mark.parametrize("ds", datasets)
def test_drop_dims(ds):

# Add data_var and coord to test _get_dims
ds["lon_var"] = ds["lon"]
ds = ds.assign_coords(lon_coord=ds["lon"])
Expand All @@ -1427,7 +1418,6 @@ def test_drop_dims(ds):

@pytest.mark.parametrize("obj", objects)
def test_rename(obj):

cf_dict = {
"air_temperature" if isinstance(obj, Dataset) else "longitude": "renamed"
}
Expand All @@ -1450,7 +1440,6 @@ def test_rename_tuple():

@pytest.mark.parametrize("ds", datasets)
def test_differentiate(ds):

# Add data_var and coord to test _get_coords
ds["lon_var"] = ds["lon"]
ds = ds.assign_coords(lon_coord=ds["lon"])
Expand Down Expand Up @@ -1710,7 +1699,6 @@ def test_regex_match():


def test_cf_standard_name_table_version() -> None:

url = (
"https://raw.githubusercontent.com/cf-convention/cf-convention.github.io/"
"master/Data/cf-standard-names/current/src/cf-standard-name-table.xml"
Expand Down Expand Up @@ -1748,7 +1736,6 @@ def test_datetime_like(reshape):
@pytest.mark.parametrize("skip", ["units", None])
@pytest.mark.parametrize("verbose", [True, False])
def test_add_canonical_attributes(override, skip, verbose, capsys):

ds = airds
original = ds.copy(deep=True)
cf_ds = ds.cf.add_canonical_attributes(
Expand Down Expand Up @@ -1834,7 +1821,6 @@ def test_flag_errors() -> None:


def test_missing_variables() -> None:

# Bounds
ds = mollwds.copy(deep=False)
ds = ds.drop_vars("lon_bounds")
Expand Down
1 change: 0 additions & 1 deletion cf_xarray/tests/test_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


def test_options():

# test for inputting a nonexistent option
with pytest.raises(ValueError):
cfxr.set_options(DISPLAY_WIDTH=80)
1 change: 0 additions & 1 deletion cf_xarray/tests/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


def test_make_doc():

names = [
"axes_criteria",
"coords_criteria",
Expand Down