-
Notifications
You must be signed in to change notification settings - Fork 300
Iris options: NetCDF #2467
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
Iris options: NetCDF #2467
Changes from 7 commits
fa8843f
d957f99
6c75714
016f829
af96e74
6f35125
6d2b735
03a8fb5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # (C) British Crown Copyright 2010 - 2016, Met Office | ||
| # (C) British Crown Copyright 2010 - 2017, Met Office | ||
| # | ||
| # This file is part of Iris. | ||
| # | ||
|
|
@@ -2244,7 +2244,10 @@ def is_valid_packspec(p): | |
| shuffle, fletcher32, contiguous, chunksizes, endian, | ||
| least_significant_digit, packing=packspec) | ||
|
|
||
| conventions = CF_CONVENTIONS_VERSION | ||
| if iris.config.netcdf.conventions_override: | ||
| conventions = cube.attributes['Conventions'] | ||
|
||
| else: | ||
| conventions = CF_CONVENTIONS_VERSION | ||
|
|
||
| # Perform a CF patch of the conventions attribute. | ||
| cf_profile_available = (iris.site_configuration.get('cf_profile') not | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # (C) British Crown Copyright 2017, Met Office | ||
| # | ||
| # This file is part of Iris. | ||
| # | ||
| # Iris is free software: you can redistribute it and/or modify it under | ||
| # the terms of the GNU Lesser General Public License as published by the | ||
| # Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Iris is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Iris. If not, see <http://www.gnu.org/licenses/>. | ||
| """Unit tests for the :mod:`iris.config` module.""" | ||
|
|
||
| from __future__ import (absolute_import, division, print_function) | ||
| from six.moves import (filter, input, map, range, zip) # noqa |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # (C) British Crown Copyright 2017, Met Office | ||
| # | ||
| # This file is part of Iris. | ||
| # | ||
| # Iris is free software: you can redistribute it and/or modify it under | ||
| # the terms of the GNU Lesser General Public License as published by the | ||
| # Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # Iris is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU Lesser General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU Lesser General Public License | ||
| # along with Iris. If not, see <http://www.gnu.org/licenses/>. | ||
| """Unit tests for the `iris.options.Paralle` class.""" | ||
|
||
|
|
||
| from __future__ import (absolute_import, division, print_function) | ||
| from six.moves import (filter, input, map, range, zip) # noqa | ||
| import six | ||
|
|
||
| # Import iris.tests first so that some things can be initialised before | ||
| # importing anything else. | ||
| import iris.tests as tests | ||
|
|
||
| import warnings | ||
|
|
||
| import iris.config | ||
|
|
||
|
|
||
| class Test(tests.IrisTest): | ||
| def test_basic(self): | ||
| self.assertFalse(iris.config.netcdf.conventions_override) | ||
|
|
||
| def test_enabled(self): | ||
| iris.config.netcdf.conventions_override = True | ||
| self.assertTrue(iris.config.netcdf.conventions_override) | ||
|
|
||
| def test_bad_value(self): | ||
| # A bad value should be ignored and replaced with the default value. | ||
| bad_value = 'wibble' | ||
| with warnings.catch_warnings(record=True) as w: | ||
| warnings.simplefilter('always') | ||
| iris.config.netcdf.conventions_override = bad_value | ||
| self.assertFalse(iris.config.netcdf.conventions_override) | ||
| exp_wmsg = 'Attempting to set invalid value {!r}'.format(bad_value) | ||
| six.assertRegex(self, str(w[0].message), exp_wmsg) | ||
|
|
||
| def test__contextmgr(self): | ||
| with iris.config.netcdf.context(conventions_override=True): | ||
| self.assertTrue(iris.config.netcdf.conventions_override) | ||
| self.assertFalse(iris.config.netcdf.conventions_override) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| tests.main() | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
@dkillick The
_defaults_dictis private to the class, so is there a real need to make this a property? I can understand making this a read-only property if it was part of the public API, but it's not, so is there a need to be this restrictive or am I missing something? (most likely)Why can't the
self._defaults_dictbe created and initialised just the once in the__init__?