Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 15, 2022
1 parent 16e4729 commit 1d77ffc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 5 additions & 1 deletion tests/test_accessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ def test_dataarray_destagger(test_grid):

@pytest.mark.parametrize('test_grid', ['lambert_conformal', 'mercator'], indirect=True)
def test_dataset_destagger(test_grid):
destaggered = test_grid.isel(Time=slice(0, 2)).xwrf.postprocess(calculate_diagnostic_variables=False).destagger()
destaggered = (
test_grid.isel(Time=slice(0, 2))
.xwrf.postprocess(calculate_diagnostic_variables=False)
.destagger()
)

# Check elimination of staggered dims and "stagger" attr
for varname in destaggered.data_vars:
Expand Down
14 changes: 10 additions & 4 deletions tests/test_destagger.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections import Counter

import numpy as np
import pytest
import xarray as xr
Expand All @@ -14,7 +15,7 @@
({'b': 3}, {}),
({'a': 4, 'c': 5}, {'a': 4, 'c': 5}),
(Counter(('a', 'a', 'b', 'c')), {'a': 2, 'c': 1}),
]
],
)
def test_drop_attrs_successful(input_attrs, output_attrs):
result = _drop_attrs(input_attrs, ('b',))
Expand All @@ -29,12 +30,17 @@ def test_drop_attrs_unsuccessful():
@pytest.mark.parametrize(
'input_name, stagger_dim, unstag_dim_name, output_name',
[
('bottom_top', 'bottom_top_stag', None, 'bottom_top',),
(
'bottom_top',
'bottom_top_stag',
None,
'bottom_top',
),
('bottom_top_stag', 'bottom_top_stag', 'z', 'z'),
('bottom_top_stag', 'bottom_top_stag', None, 'bottom_top'),
('XLAT_U', 'west_east', None, 'XLAT'),
('XLONG_V', 'south_north', None, 'XLONG'),
]
],
)
def test_rename_staggered_coordinate(input_name, stagger_dim, unstag_dim_name, output_name):
assert _rename_staggered_coordinate(input_name, stagger_dim, unstag_dim_name) == output_name
Expand All @@ -55,7 +61,7 @@ def test_destag_variable_multiple_dims():
[
('z', 'z'),
(None, 'bottom_top'),
]
],
)
def test_destag_variable_1d(unstag_dim_name, expected_output_dim_name):
staggered = xr.Variable(('bottom_top_stag',), np.arange(5), attrs={'stagger': 'Z'})
Expand Down

0 comments on commit 1d77ffc

Please sign in to comment.