Skip to content

Commit

Permalink
Patches (#191)
Browse files Browse the repository at this point in the history
* Bump black versions to the supported ones

* Register network marker for pytest

* Replaced pkg_resources with importlib because of depreciation in 3.12

* Fixed test warning by dropping duplicate coordinate

* Disabled test because dataset has no horizontal extent

* Suppress uneccessary xgcm DeprecationWarning for Axis which we don't use
  • Loading branch information
lpilz authored Oct 11, 2024
1 parent 7631f6c commit 79721d7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[tool.black]
line-length = 100
target-version = ['py39', 'py310', 'py311', 'py312']
target-version = ["py310", "py311", "py312"]
skip-string-normalization = true

[tool.pytest.ini_options]
markers = [
"network: mark test as requiring network access",
]

[build-system]
requires = ["setuptools>=30.3.0", "wheel", "setuptools_scm"]
2 changes: 1 addition & 1 deletion tests/test_metpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_metpy_coordinate_identification(sample_dataset):
indirect=['sample_dataset'],
)
def test_metpy_axis_identification(sample_dataset, axis_mapping, test_varname):
da = sample_dataset.xwrf.postprocess()[test_varname]
da = sample_dataset.xwrf.postprocess()[test_varname].drop_vars('CLAT')
for axis_type, axis_number in axis_mapping.items():
assert da.metpy.find_axis_number(axis_type) == axis_number
assert da.metpy.find_axis_name(axis_type) == da.dims[axis_number]
7 changes: 5 additions & 2 deletions tests/test_postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ def test_include_projection_coordinates(sample_dataset):


@pytest.mark.parametrize(
'sample_dataset', set(xwrf.tutorial.sample_datasets.keys()) - {'tiny', 'ideal'}, indirect=True
'sample_dataset',
set(xwrf.tutorial.sample_datasets.keys()) - {'tiny', 'ideal', 'dummy_attrs_only'},
indirect=True,
)
def test_grid_mapping_is_in_all_vars(sample_dataset):
dataset = xwrf.postprocess._include_projection_coordinates(sample_dataset)
Expand All @@ -77,7 +79,8 @@ def test_include_projection_coordinates_with_xgcm(sample_dataset):
from xgcm import Grid

dataset = xwrf.postprocess._include_projection_coordinates(sample_dataset)
grid = Grid(dataset)
with pytest.warns(DeprecationWarning):
grid = Grid(dataset, periodic=False)

assert grid.axes['Y'].coords['center'] == 'south_north'
assert grid.axes['Y'].coords['outer'] == 'south_north_stag'
Expand Down
6 changes: 3 additions & 3 deletions xwrf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# flake8: noqa
""" Top-level module. """

from pkg_resources import DistributionNotFound, get_distribution
from importlib.metadata import PackageNotFoundError, version

from . import postprocess, tutorial
from .accessors import WRFDataArrayAccessor, WRFDatasetAccessor
from .config import config
from .version_report import show_versions

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound: # pragma: no cover
__version__ = version(__name__)
except PackageNotFoundError: # pragma: no cover
__version__ = 'unknown' # pragma: no cover

0 comments on commit 79721d7

Please sign in to comment.