-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated tests for cf_units 2 #3023
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 4 additions & 0 deletions
4
docs/iris/src/whatsnew/contributions_2.1/newfeature_2018-May-22_cf_units_2.txt
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,4 @@ | ||
Iris updated its cf_units dependency to cf_units v2. cf_units 2 is almost entirely backwards compatible, | ||
although the ability to preserve some alias calendars has been removed. For this reason, it is possible | ||
that NetCDF load of a variable with a "standard" calendar will result in a saved NetCDF of a "gregorian" | ||
calendar. |
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
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,4 +1,4 @@ | ||
# (C) British Crown Copyright 2013 - 2017, Met Office | ||
# (C) British Crown Copyright 2013 - 2018, Met Office | ||
# | ||
# This file is part of Iris. | ||
# | ||
|
@@ -101,18 +101,22 @@ def test_time_360(self): | |
time_coord = DimCoord([0, 100.1, 200.2, 300.3, 400.4], | ||
long_name="time", units=time_unit) | ||
cube.add_dim_coord(time_coord, 0) | ||
if netCDF4.__version__ > '1.2.4': | ||
# TODO Remove this if statement as we move to cftime | ||
if cf_units.__version__ > '1': | ||
import cftime | ||
expected_index = [cftime.Datetime360Day(2000, 1, 1, 0, 0), | ||
cftime.Datetime360Day(2000, 4, 11, 2, 24), | ||
cftime.Datetime360Day(2000, 7, 21, 4, 48), | ||
cftime.Datetime360Day(2000, 11, 1, 7, 12), | ||
cftime.Datetime360Day(2001, 2, 11, 9, 36)] | ||
|
||
else: | ||
expected_index = [netcdftime.Datetime360Day(2000, 1, 1, 0, 0), | ||
netcdftime.Datetime360Day(2000, 4, 11, 2, 24), | ||
netcdftime.Datetime360Day(2000, 7, 21, 4, 48), | ||
netcdftime.Datetime360Day(2000, 11, 1, 7, 12), | ||
netcdftime.Datetime360Day(2001, 2, 11, 9, 36)] | ||
else: | ||
expected_index = [netcdftime.datetime(2000, 1, 1, 0, 0), | ||
netcdftime.datetime(2000, 4, 11, 2, 24), | ||
netcdftime.datetime(2000, 7, 21, 4, 48), | ||
netcdftime.datetime(2000, 11, 1, 7, 12), | ||
netcdftime.datetime(2001, 2, 11, 9, 36)] | ||
|
||
series = iris.pandas.as_series(cube) | ||
self.assertArrayEqual(series, cube.data) | ||
self.assertArrayEqual(series.index, expected_index) | ||
|
@@ -244,12 +248,16 @@ def test_time_360(self): | |
time_coord = DimCoord([100.1, 200.2], long_name="time", | ||
units=time_unit) | ||
cube.add_dim_coord(time_coord, 0) | ||
if netCDF4.__version__ > '1.2.4': | ||
# TODO: Remove this if statement once we move to exclusive cftime. | ||
if cf_units.__version__ > '1': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is really ugly, but will be removed with #3016. |
||
# cf_units depends upon cftime, so we can safely assume we | ||
# have it. | ||
import cftime | ||
expected_index = [cftime.Datetime360Day(2000, 4, 11, 2, 24), | ||
cftime.Datetime360Day(2000, 7, 21, 4, 48)] | ||
else: | ||
expected_index = [netcdftime.Datetime360Day(2000, 4, 11, 2, 24), | ||
netcdftime.Datetime360Day(2000, 7, 21, 4, 48)] | ||
else: | ||
expected_index = [netcdftime.datetime(2000, 4, 11, 2, 24), | ||
netcdftime.datetime(2000, 7, 21, 4, 48)] | ||
expected_columns = [0, 1, 2, 3, 4] | ||
data_frame = iris.pandas.as_data_frame(cube) | ||
self.assertArrayEqual(data_frame, cube.data) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really ugly, but will be removed with #3016.