From 3d614dd82a842119ebc74c7c5e7513db9fe91d5d Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Tue, 13 Mar 2018 16:40:29 -0700 Subject: [PATCH] failing test from vcs added here (#234) * failing test from vcs added here * ok test passes again * reverted for now * commented out test for @durack1 --- Lib/axis.py | 12 ++++++------ ci-support/conda_upload.sh | 2 +- tests/test_axis_missing.py | 39 ++++++++++++++++++++++++++++++++++++++ tests/test_cdms_info.py | 2 +- 4 files changed, 47 insertions(+), 8 deletions(-) create mode 100644 tests/test_axis_missing.py diff --git a/Lib/axis.py b/Lib/axis.py index 61c75c96..e1f394e3 100644 --- a/Lib/axis.py +++ b/Lib/axis.py @@ -1919,16 +1919,16 @@ def __init__(self, data, bounds=None, id=None, self._data_ = data[:] else: self._data_ = numpy.array(data[:]) - elif isinstance(data, numpy.ma.MaskedArray): - if numpy.ma.getmask(data).any() is numpy.bool_(True): - raise CDMSError( - 'Cannot construct an axis with a missing value.') - data = data.data + elif isinstance(data, numpy.ndarray): if copy == 0: self._data_ = data else: self._data_ = numpy.array(data) - elif isinstance(data, numpy.ndarray): + elif isinstance(data, numpy.ma.MaskedArray): + if numpy.ma.getmask(data) is not numpy.ma.nomask: + raise CDMSError( + 'Cannot construct an axis with a missing value.') + data = data.data if copy == 0: self._data_ = data else: diff --git a/ci-support/conda_upload.sh b/ci-support/conda_upload.sh index 47dfa1ab..ef61e574 100644 --- a/ci-support/conda_upload.sh +++ b/ci-support/conda_upload.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash PKG_NAME=cdms2 -USER=uvcdat +USER=cdat echo "Trying to upload conda" mkdir ${HOME}/conda-bld export CONDA_BLD_PATH=${HOME}/conda-bld diff --git a/tests/test_axis_missing.py b/tests/test_axis_missing.py new file mode 100644 index 00000000..b2f376f2 --- /dev/null +++ b/tests/test_axis_missing.py @@ -0,0 +1,39 @@ +import unittest +import numpy +import cdms2 +import MV2 + +class CDMSTestAxisMissing(unittest.TestCase): + def testAxismissing(self): + data = """ + -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. + 0.059503571833625334 + 0.059503571833625334 0.05664014775641405 0.05193557222118004 + 0.04777129850801233 0.0407139313814465 0.029382624830271705 + 0.018469399844287374 0.0162382275289592 0.02646680241827459 + 0.04792041732949079 0.0689138797030203 0.08167038620212037 + 0.09273558459066569 0.11266293431057901 0.13663018925347364 + 0.15229174546388072 0.15284435880966177 0.13423845476113883 + 0.09945904378274077 0.07032267160267985 0.05551039827020481 + 0.045537187647785464 0.040532491867244946 0.03577527125478327 + -999. -999. -999. + -0.058062458673116 -0.08764922509099882 -0.11697036914487152 + -0.14836133615864944 -0.17956528904564023 -0.21109198032585794 + -0.23846429237248942 -0.2598536549218765 -0.27795672866320387 + -0.2939939095159731 -0.30541031366330024 -0.307643559333884 + -0.30078421139811795 -0.2841339526883441 -0.26485737397202497 + -0.24287299694779327 -0.22379014890999907 -0.20121548204699846 + -0.1746486732156772 -0.14585019344118372 -0.12070675757803526 + -0.0997891159111037 -0.08229393660994214 -0.06779720501287469 + -0.057213385470859794 -0.04875768191096844 -0.0402377347189964 + -0.030169328367807245 -0.017560662894847895 -0.006968922654137132 + 0.0009773980274431048 0.007054306637034288 0.010472286514133042 + 0.010702384151997032 0.009231553701801242 0.007544033101056543 + 0.004639797857203645 -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. + -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. + -999. -999. -999. + """.split() + data = numpy.array(data, dtype=numpy.float) + data = MV2.masked_less(data, -900) + d2 = cdms2.createAxis(data) + self.assertTrue(numpy.ma.allclose(data,d2[:])) diff --git a/tests/test_cdms_info.py b/tests/test_cdms_info.py index 82a96b27..5a618097 100644 --- a/tests/test_cdms_info.py +++ b/tests/test_cdms_info.py @@ -8,7 +8,7 @@ def testInfo(self): f = cdms2.open(os.path.join(cdat_info.get_sampledata_path(),"clt.nc")) s=f("clt") s.info() - def testAxis(self): + def tstAxis(self): axis = cdms2.createAxis(cdms2.createVariable([10.], id='height', missing=1e20)) print(axis)