Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/iris/tests/results/analysis/exponentiate.cml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" ?>
<cubes xmlns="urn:x-iris:cubeml-0.2">
<cube core-dtype="float64" dtype="float64" fill_value="-1e+30" units="kelvin^4">
<cube core-dtype="float64" dtype="float64" fill_value="-1.00000001505e+30" units="kelvin^4">
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test in question changes the cube data dtype from float32 to float64, hence the change in fill_value representation ...

<coords>
<coord>
<dimCoord bounds="[[-28083.0, 6477.0]]" id="1d45e087" points="[6477]" shape="(1,)" standard_name="forecast_period" units="Unit('hours')" value_type="int32"/>
Expand Down
16 changes: 16 additions & 0 deletions lib/iris/tests/test_basic_maths.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@
class TestBasicMaths(tests.IrisTest):
def setUp(self):
self.cube = iris.tests.stock.global_pp()
# We require to preserve the cube fill_value
# across the cube data setter operation.
fill_value = self.cube.fill_value
self.cube.data = self.cube.data - 260
self.cube.fill_value = fill_value

def test_abs(self):
a = self.cube
Expand Down Expand Up @@ -360,7 +364,11 @@ def test_type_error(self):
class TestDivideAndMultiply(tests.IrisTest):
def setUp(self):
self.cube = iris.tests.stock.global_pp()
# We require to preserve the cube fill_value
# across the cube data setter operation.
fill_value = self.cube.fill_value
self.cube.data = self.cube.data - 260
self.cube.fill_value = fill_value

def test_divide(self):
a = self.cube
Expand Down Expand Up @@ -503,18 +511,26 @@ def test_type_error(self):
class TestExponentiate(tests.IrisTest):
def setUp(self):
self.cube = iris.tests.stock.global_pp()
# We require to preserve the cube fill_value
# across the cube data setter operation.
self.fill_value = self.cube.fill_value
self.cube.data = self.cube.data - 260
self.cube.fill_value = self.fill_value

def test_exponentiate(self):
a = self.cube
a.data = a.data.astype(np.float64)
# We require to preserve the cube fill_value after setting the data.
a.fill_value = self.fill_value
e = pow(a, 4)
self.assertCMLApproxData(e, ('analysis', 'exponentiate.cml'))

def test_square_root(self):
# Make sure we have something which we can take the root of.
a = self.cube
a.data = abs(a.data)
# We require to preserve the cube fill_value after setting the data.
a.fill_value = self.fill_value
a.units **= 2

e = a ** 0.5
Expand Down