-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allowing exemption to axis guessing on coords (#5551)
* allowing excemption to axis guessing on coords * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * updating pr * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * remove from metadata * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * remove merge clash * adding review comments * more review changes * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * parametrise and add tests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix last test * addressing review comments * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix test failure * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add whatsnew and conftest files * fix sentence * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix flake8 * fix last test * update whatsnew --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
80c1792
commit 7770518
Showing
6 changed files
with
146 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright Iris contributors | ||
# | ||
# This file is part of Iris and is released under the BSD license. | ||
# See LICENSE in the root of the repository for full licensing details. | ||
"""Unit tests fixture infra-structure.""" | ||
import pytest | ||
|
||
import iris | ||
|
||
|
||
@pytest.fixture | ||
def sample_coord(): | ||
sample_coord = iris.coords.DimCoord(points=(1, 2, 3, 4, 5)) | ||
return sample_coord |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright Iris contributors | ||
# | ||
# This file is part of Iris and is released under the BSD license. | ||
# See LICENSE in the root of the repository for full licensing details. | ||
"""Test function :func:`iris.util.guess_coord_axis`.""" | ||
|
||
import pytest | ||
|
||
from iris.util import guess_coord_axis | ||
|
||
|
||
class TestGuessCoord: | ||
@pytest.mark.parametrize( | ||
"coordinate, axis", | ||
[ | ||
("longitude", "X"), | ||
("grid_longitude", "X"), | ||
("projection_x_coordinate", "X"), | ||
("latitude", "Y"), | ||
("grid_latitude", "Y"), | ||
("projection_y_coordinate", "Y"), | ||
], | ||
) | ||
def test_coord(self, coordinate, axis, sample_coord): | ||
sample_coord.standard_name = coordinate | ||
assert guess_coord_axis(sample_coord) == axis | ||
|
||
@pytest.mark.parametrize( | ||
"units, axis", | ||
[ | ||
("hPa", "Z"), | ||
("days since 1970-01-01 00:00:00", "T"), | ||
], | ||
) | ||
def test_units(self, units, axis, sample_coord): | ||
sample_coord.units = units | ||
assert guess_coord_axis(sample_coord) == axis | ||
|
||
@pytest.mark.parametrize( | ||
"ignore_axis, result", | ||
[ | ||
(True, None), | ||
(False, "X"), | ||
], | ||
) | ||
def test_ignore_axis(self, ignore_axis, result, sample_coord): | ||
sample_coord.standard_name = "longitude" | ||
sample_coord.ignore_axis = ignore_axis | ||
|
||
assert guess_coord_axis(sample_coord) == result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters