Skip to content

Commit

Permalink
fix squeeze CDAT/cdat/issues/1707
Browse files Browse the repository at this point in the history
  • Loading branch information
dnadeau4 committed Nov 30, 2017
1 parent 276715c commit 4c14ce6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
21 changes: 12 additions & 9 deletions Lib/hgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,14 +588,16 @@ def getGridSlices(self, domainlist, newaxislist, slicelist):
k = 0
i = j = -1
for d in domainlist:
if d is iaxis:
inewaxis = newaxislist[k]
islice = slicelist[k]
i = k
if d is jaxis:
jnewaxis = newaxislist[k]
jslice = slicelist[k]
j = k
if d.shape == iaxis.shape:
if numpy.allclose(d[:], iaxis[:]) == True:
inewaxis = newaxislist[k]
islice = slicelist[k]
i = k
if d.shape == jaxis.shape:
if numpy.allclose(d[:], jaxis[:]) == True:
jnewaxis = newaxislist[k]
jslice = slicelist[k]
j = k
k += 1

if i == -1 or j == -1:
Expand Down Expand Up @@ -677,7 +679,8 @@ def isClose(self, g):
def checkAxes(self, axes):
"""Return 1 iff every element of self.getAxisList() is in the list 'axes'."""
for item in self.getAxisList():
if item.shape not in [axis.shape for axis in axes]:
# if all [False, False, ....] result=0
if not any([allclose(item[:],axis[:]) for axis in axes]):
result = 0
break
else:
Expand Down
10 changes: 10 additions & 0 deletions tests/test_curvilinear_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,19 @@
import os
import sys
import basetest
import copy


class TestCurvilinearGrids(basetest.CDMSBaseTest):

def testReadCurvGrid(self):
f = self.getDataFile('sampleCurveGrid4.nc')
data = f("sample")
attrs = copy.copy(data.attributes)
axes = list([x[0].clone() for x in data.getDomain()])
data2 = cdms2.createVariable(data, copy=0, attributes=attrs, axes=axes)
data3=data2(*(),squeeze=1)

def testCurvilinear(self):
datb = numpy.array(
[[697., 698., 699., 700., 701., 702., ],
Expand Down

0 comments on commit 4c14ce6

Please sign in to comment.