-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatic reversal of DimCoord bounds (#4466)
* first pass at ensuring contiguous bounds * reduce scope and fix old tests * bounds setter tests * test contiguity preserved * check bounds within reverse tests * add comment; merge test * simpler approach * revert now redundant changes * update cml * cell equality to ignore bound order * update cml * move merge test to integration * review: simple actions * review: split up cube reverse tests * review: check bounds in all cube reverse tests * whatsnew * review: reduce test repetition * tweak whatsnew * blank line
- Loading branch information
Showing
10 changed files
with
176 additions
and
76 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,6 @@ | ||
# Copyright Iris contributors | ||
# | ||
# This file is part of Iris and is released under the LGPL license. | ||
# See COPYING and COPYING.LESSER in the root of the repository for full | ||
# licensing details. | ||
"""Integration tests for the :mod:`iris._merge` package.""" |
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,37 @@ | ||
# Copyright Iris contributors | ||
# | ||
# This file is part of Iris and is released under the LGPL license. | ||
# See COPYING and COPYING.LESSER in the root of the repository for full | ||
# licensing details. | ||
""" | ||
Integration tests for merging cubes. | ||
""" | ||
|
||
# import iris tests first so that some things can be initialised | ||
# before importing anything else. | ||
import iris.tests as tests # isort:skip | ||
|
||
from iris.coords import DimCoord | ||
from iris.cube import Cube, CubeList | ||
|
||
|
||
class TestContiguous(tests.IrisTest): | ||
def test_form_contiguous_dimcoord(self): | ||
# Test that cube sliced up and remerged in the opposite order maintains | ||
# contiguity. | ||
cube1 = Cube([1, 2, 3], "air_temperature", units="K") | ||
coord1 = DimCoord([3, 2, 1], long_name="spam") | ||
coord1.guess_bounds() | ||
cube1.add_dim_coord(coord1, 0) | ||
cubes = CubeList(cube1.slices_over("spam")) | ||
cube2 = cubes.merge_cube() | ||
coord2 = cube2.coord("spam") | ||
|
||
self.assertTrue(coord2.is_contiguous()) | ||
self.assertArrayEqual(coord2.points, [1, 2, 3]) | ||
self.assertArrayEqual(coord2.bounds, coord1.bounds[::-1, ::-1]) | ||
|
||
|
||
if __name__ == "__main__": | ||
tests.main() |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<?xml version="1.0" ?> | ||
<dimCoord bounds="[[27.75, 30.75], | ||
[24.75, 27.75], | ||
[21.75, 24.75], | ||
[18.75, 21.75], | ||
[15.75, 18.75], | ||
[12.75, 15.75], | ||
[9.75, 12.75], | ||
[6.75, 9.75]]" id="43cd7f4a" long_name="foo" points="[30.0, 27.0, 24.0, 21.0, 18.0, 15.0, 12.0, 9.0]" shape="(8,)" units="Unit('meter')" value_type="float32"/> | ||
<dimCoord bounds="[[30.75, 27.75], | ||
[27.75, 24.75], | ||
[24.75, 21.75], | ||
[21.75, 18.75], | ||
[18.75, 15.75], | ||
[15.75, 12.75], | ||
[12.75, 9.75], | ||
[9.75, 6.75]]" id="43cd7f4a" long_name="foo" points="[30.0, 27.0, 24.0, 21.0, 18.0, 15.0, 12.0, 9.0]" shape="(8,)" units="Unit('meter')" value_type="float32"/> |
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
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