From c2d8bd375d8a10cf0d9a1c01063b616717286d92 Mon Sep 17 00:00:00 2001 From: Denis Nadeau Date: Tue, 6 Mar 2018 21:48:40 -0800 Subject: [PATCH] Issue#231 (#232) * fix #225 passing transiant variable as axis * Fix macOSX * fix ESMF and NPY_STRING * fix data._mask comparison for numpy 1.14 --- Lib/axis.py | 12 ++++++------ tests/test_EsmfMask.py | 9 +-------- tests/test_cdms_info.py | 2 +- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/Lib/axis.py b/Lib/axis.py index b2c71df1..15a706cb 100644 --- a/Lib/axis.py +++ b/Lib/axis.py @@ -1932,13 +1932,8 @@ def __init__(self, data, bounds=None, id=None, self._data_ = data[:] else: self._data_ = numpy.array(data[:]) - elif isinstance(data, numpy.ndarray): - if copy == 0: - self._data_ = data - else: - self._data_ = numpy.array(data) elif isinstance(data, numpy.ma.MaskedArray): - if numpy.ma.getmask(data) is not numpy.ma.nomask: + if numpy.ma.getmask(data).any() is numpy.bool_(True): raise CDMSError( 'Cannot construct an axis with a missing value.') data = data.data @@ -1946,6 +1941,11 @@ def __init__(self, data, bounds=None, id=None, self._data_ = data else: self._data_ = numpy.array(data) + elif isinstance(data, numpy.ndarray): + if copy == 0: + self._data_ = data + else: + self._data_ = numpy.array(data) elif data is None: self._data_ = None else: diff --git a/tests/test_EsmfMask.py b/tests/test_EsmfMask.py index 60da15ac..e401b6cb 100644 --- a/tests/test_EsmfMask.py +++ b/tests/test_EsmfMask.py @@ -1,6 +1,5 @@ import unittest import cdms2 -import vcs import ESMF import cdat_info import os @@ -61,16 +60,10 @@ def testMask2(self): data2 = cdms2.MV2.masked_where(cdms2.MV2.less(sft,50.),data) tGrid = cdms2.createUniformGrid(-88.875, 72, 2.5, 0, 144, 2.5) - x=vcs.init() + for mthd in ["conservative", "linear"]: print("USING REGRID METHOD:",mthd) data3 = data2.regrid(tGrid, regridTool="esmf", regridMethod=mthd, mask=data2.mask) - print("pltting") - x.plot(data3) - print("pnging") - x.png("masked_{}".format(mthd)) - print("clearing") - x.clear() diff --git a/tests/test_cdms_info.py b/tests/test_cdms_info.py index 5a618097..82a96b27 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 tstAxis(self): + def testAxis(self): axis = cdms2.createAxis(cdms2.createVariable([10.], id='height', missing=1e20)) print(axis)