Skip to content

Commit 40def23

Browse files
bjlittletkknightznichollstrexfeathersjonseddon
authored
Merge back v3p0p1 (#3966)
* Add release highlights and pin rc version (#3898) * Add release highlights and pin rc version * review actions * reorder release highlights (#3899) Tweak release highlights * Add whatsnew announcement (#3900) * Fix spelling (#3903) * Fix unit label handling (#3902) * Add failing test of plotting * Implement fix to pass test * Update idiff to ignore irrelevant hyphens in path * Update imagerepo (following docs) * Update after review by @trexfeathers * Add whatsnew entries * Move whatsnew entries into correct file * Release Docs Improvements (#3895) * Minor phrasing change in 'Release candidate'. * Before release deprecations. * Whatsnew highlights section. * Relax setup.py setup requirements (#3909) * Updated CF saver version in User Guide and docstring (#3925) * Updated CF saver version in User Guide and docstring * Remove references to CF version of the loader in docstrings * Added whatsnew * Pin cftime<1.3.0 * Migrate to cirrus-ci (#3928) * migrate from travis-ci to cirrus-ci * added whatsnew entries * ignore url for doc link check (#3929) * whatsnew for coord default units (#3924) * Cube._summary_coord_extra: efficiency and bugfix (#3922) * Add Documentation Title Case Capitalization (#3940) * Use Title Case Capitalisation for Documentation * add whatsnew enter * CI requirements drop pip packages (#3939) * requirements pip to conda * use pip install over develop * default PY_VER to python versions * update links (#3942) * update links * added s to http * Add support for 1-d weights in collapse. (#3943) * Remove warning for convert_units on lazy data (#3951) * drop stickler references in docs (#3953) * drop stickler references in docs * remove sticker from common links * update docs for travis-ci to cirrus-ci (#3954) * update docs for travis-ci to cirrus-ci * add 'travis-ci' reference locally to whatsnew * update whatsnew comment * docs for nox (#3955) * docs for nox * add titles, notices and additional detail * review actions * Resolve test coverage (#3947) * test coverage for __init__ and __call__ * test coverage for metadata resolve and coverage * partial test coverage for metadata mapping * python 3.6 workaround for deepcopy of mock.sentinel * test coverage for Resolve._free_mapping * test coverage for Resolve convenience methods * add test stub for Resolve._metadata_mapping * fix Test__tgt_cube_position * test coverage for shape * test coverage for _as_compatible_cubes * test coverage for Resolve._metadata_mapping * test coverage for Resolve._prepare_common_dim_payload * test coverage for Resolve._prepare_common_aux_payload * test coverage for Resolve._prepare_points_and_bounds * test coverage for Resolve._create_prepared_item * test coverage for Resolve._prepare_local_payload_dim * test coverage for Resolve._prepare_local_payload_aux * test coverage for Resolve._prepare_local_payload_scalar + docs URL skip * test coverage for Resolve._prepare_local_payload * test coverage for Resolve._metadata_prepare * added docs URL linkcheck skip * test coverage for Resolve._prepare_factory_payload * test coverage for Resolve._get_prepared_item * review actions * test coverage for Resolve.cube * pin v3.0.0 version and whatnew date (#3956) * update github ci checks image (#3957) * Promote unknown units to dimensionless in aux factories (#3965) * promote unknown to dimensionless units in aux factories * patch aux factories to promote unknown to dimensionless units for formula terms * add whatnew PR for entry Co-authored-by: tkknight <[email protected]> Co-authored-by: Zeb Nicholls <[email protected]> Co-authored-by: Martin Yeo <[email protected]> Co-authored-by: Jon Seddon <[email protected]> Co-authored-by: Ruth Comer <[email protected]> Co-authored-by: Patrick Peglar <[email protected]>
1 parent f0d72f7 commit 40def23

File tree

12 files changed

+635
-4
lines changed

12 files changed

+635
-4
lines changed

docs/iris/src/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ def autolog(message):
8282
if iris.__version__ == "dev":
8383
version = "dev"
8484
else:
85-
# major.feature(.minor)-dev -> major.minor
86-
version = ".".join(iris.__version__.split("-")[0].split(".")[:2])
85+
# major.minor.patch-dev -> major.minor.patch
86+
version = ".".join(iris.__version__.split("-")[0].split(".")[:3])
8787
# The full version, including alpha/beta/rc tags.
8888
release = iris.__version__
8989

docs/iris/src/whatsnew/3.0.1.rst

Lines changed: 520 additions & 0 deletions
Large diffs are not rendered by default.

docs/iris/src/whatsnew/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Iris versions.
1111
:maxdepth: 1
1212

1313
latest.rst
14+
3.0.1.rst
1415
3.0.rst
1516
2.4.rst
1617
2.3.rst

lib/iris/aux_factory.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from abc import ABCMeta, abstractmethod
1212
import warnings
1313

14+
import cf_units
1415
import dask.array as da
1516
import numpy as np
1617

@@ -619,6 +620,10 @@ def _check_dependencies(delta, sigma, surface_air_pressure):
619620
warnings.warn(msg, UserWarning, stacklevel=2)
620621

621622
# Check units.
623+
if sigma is not None and sigma.units.is_unknown():
624+
# Be graceful, and promote unknown to dimensionless units.
625+
sigma.units = cf_units.Unit("1")
626+
622627
if sigma is not None and not sigma.units.is_dimensionless():
623628
raise ValueError("Invalid units: sigma must be dimensionless.")
624629
if (
@@ -863,6 +868,10 @@ def _check_dependencies(sigma, eta, depth, depth_c, nsigma, zlev):
863868
)
864869
raise ValueError(msg)
865870

871+
if sigma is not None and sigma.units.is_unknown():
872+
# Be graceful, and promote unknown to dimensionless units.
873+
sigma.units = cf_units.Unit("1")
874+
866875
if sigma is not None and not sigma.units.is_dimensionless():
867876
msg = (
868877
"Invalid units: sigma coordinate {!r} "
@@ -1127,6 +1136,10 @@ def _check_dependencies(sigma, eta, depth):
11271136
warnings.warn(msg, UserWarning, stacklevel=2)
11281137

11291138
# Check units.
1139+
if sigma is not None and sigma.units.is_unknown():
1140+
# Be graceful, and promote unknown to dimensionless units.
1141+
sigma.units = cf_units.Unit("1")
1142+
11301143
if sigma is not None and not sigma.units.is_dimensionless():
11311144
msg = (
11321145
"Invalid units: sigma coordinate {!r} "
@@ -1335,6 +1348,10 @@ def _check_dependencies(s, c, eta, depth, depth_c):
13351348
# Check units.
13361349
coords = ((s, "s"), (c, "c"))
13371350
for coord, term in coords:
1351+
if coord is not None and coord.units.is_unknown():
1352+
# Be graceful, and promote unknown to dimensionless units.
1353+
coord.units = cf_units.Unit("1")
1354+
13381355
if coord is not None and not coord.units.is_dimensionless():
13391356
msg = (
13401357
"Invalid units: {} coordinate {!r} "
@@ -1551,6 +1568,10 @@ def _check_dependencies(s, eta, depth, a, b, depth_c):
15511568
raise ValueError(msg)
15521569

15531570
# Check units.
1571+
if s is not None and s.units.is_unknown():
1572+
# Be graceful, and promote unknown to dimensionless units.
1573+
s.units = cf_units.Unit("1")
1574+
15541575
if s is not None and not s.units.is_dimensionless():
15551576
msg = (
15561577
"Invalid units: s coordinate {!r} "
@@ -1776,6 +1797,10 @@ def _check_dependencies(s, c, eta, depth, depth_c):
17761797
# Check units.
17771798
coords = ((s, "s"), (c, "c"))
17781799
for coord, term in coords:
1800+
if coord is not None and coord.units.is_unknown():
1801+
# Be graceful, and promote unknown to dimensionless units.
1802+
coord.units = cf_units.Unit("1")
1803+
17791804
if coord is not None and not coord.units.is_dimensionless():
17801805
msg = (
17811806
"Invalid units: {} coordinate {!r} "

lib/iris/fileformats/netcdf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,9 @@ def coord_from_term(term):
719719
warnings.warn(msg)
720720
coord_a = coord_from_term("a")
721721
if coord_a is not None:
722+
if coord_a.units.is_unknown():
723+
# Be graceful, and promote unknown to dimensionless units.
724+
coord_a.units = "1"
722725
delta = coord_a * coord_p0.points[0]
723726
delta.units = coord_a.units * coord_p0.units
724727
delta.rename("vertical pressure")

lib/iris/tests/unit/aux_factory/test_HybridPressureFactory.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,15 @@ def test_factory_metadata(self):
113113
self.assertIsNone(factory.coord_system)
114114
self.assertEqual(factory.attributes, {})
115115

116+
def test_promote_sigma_units_unknown_to_dimensionless(self):
117+
sigma = mock.Mock(units=cf_units.Unit("unknown"), nbounds=0)
118+
factory = HybridPressureFactory(
119+
delta=self.delta,
120+
sigma=sigma,
121+
surface_air_pressure=self.surface_air_pressure,
122+
)
123+
self.assertEqual("1", factory.dependencies["sigma"].units)
124+
116125

117126
class Test_dependencies(tests.IrisTest):
118127
def setUp(self):

lib/iris/tests/unit/aux_factory/test_OceanSFactory.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ def test_depth_incompatible_units(self):
137137
with self.assertRaises(ValueError):
138138
OceanSFactory(**self.kwargs)
139139

140+
def test_promote_s_units_unknown_to_dimensionless(self):
141+
s = mock.Mock(units=Unit("unknown"), nbounds=0)
142+
self.kwargs["s"] = s
143+
factory = OceanSFactory(**self.kwargs)
144+
self.assertEqual("1", factory.dependencies["s"].units)
145+
140146

141147
class Test_dependencies(tests.IrisTest):
142148
def setUp(self):

lib/iris/tests/unit/aux_factory/test_OceanSg1Factory.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@ def test_depth_incompatible_units(self):
121121
with self.assertRaises(ValueError):
122122
OceanSg1Factory(**self.kwargs)
123123

124+
def test_promote_c_and_s_units_unknown_to_dimensionless(self):
125+
c = mock.Mock(units=Unit("unknown"), nbounds=0)
126+
s = mock.Mock(units=Unit("unknown"), nbounds=0)
127+
self.kwargs["c"] = c
128+
self.kwargs["s"] = s
129+
factory = OceanSg1Factory(**self.kwargs)
130+
self.assertEqual("1", factory.dependencies["c"].units)
131+
self.assertEqual("1", factory.dependencies["s"].units)
132+
124133

125134
class Test_dependencies(tests.IrisTest):
126135
def setUp(self):

lib/iris/tests/unit/aux_factory/test_OceanSg2Factory.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@ def test_depth_incompatible_units(self):
121121
with self.assertRaises(ValueError):
122122
OceanSg2Factory(**self.kwargs)
123123

124+
def test_promote_c_and_s_units_unknown_to_dimensionless(self):
125+
c = mock.Mock(units=Unit("unknown"), nbounds=0)
126+
s = mock.Mock(units=Unit("unknown"), nbounds=0)
127+
self.kwargs["c"] = c
128+
self.kwargs["s"] = s
129+
factory = OceanSg2Factory(**self.kwargs)
130+
self.assertEqual("1", factory.dependencies["c"].units)
131+
self.assertEqual("1", factory.dependencies["s"].units)
132+
124133

125134
class Test_dependencies(tests.IrisTest):
126135
def setUp(self):

lib/iris/tests/unit/aux_factory/test_OceanSigmaFactory.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ def test_depth_incompatible_units(self):
5959
with self.assertRaises(ValueError):
6060
OceanSigmaFactory(**self.kwargs)
6161

62+
def test_promote_sigma_units_unknown_to_dimensionless(self):
63+
sigma = mock.Mock(units=Unit("unknown"), nbounds=0)
64+
self.kwargs["sigma"] = sigma
65+
factory = OceanSigmaFactory(**self.kwargs)
66+
self.assertEqual("1", factory.dependencies["sigma"].units)
67+
6268

6369
class Test_dependencies(tests.IrisTest):
6470
def setUp(self):

0 commit comments

Comments
 (0)