示例#1
0
xtr.shape = (4, 6)
xtr1 = MV2.transpose(xtr)
xtr2 = MV2.transpose(MV2.TransientVariable(xtr))
if not xtr2.shape == (6, 4): markError('transpose shape')
xtr3 = numpy.transpose(xtr)
if not MV2.allclose(xtr1, xtr3): markError('transpose 2')
if not MV2.allclose(xtr2, xtr3): markError('transpose 1')

## where(condition, x, y)
##   where(condition, x, y) is x where condition is true, y otherwise
xwhere = MV2.where(MV2.greater(xouter, 200), xouter, MV2.masked)
xwhere2 = MV2.where(MV2.greater(ud, 200), ud, MV2.masked)
xwhere3 = MV2.where(MV2.greater(uf, 200), uf, MV2.masked)
xwhere2 = MV2.choose(MV2.greater(xouter, 200), (MV2.masked, xouter))
if not MV2.allclose(xwhere, xwhere2): markError('where test 1')

## diagonal(x, k)
xdiag = MV2.TransientVariable([[1, 2, 3], [4, 5, 6]])
if not MV2.allclose(MV2.diagonal(xdiag, 1), [2, 6]): markError('diagonal')
# Broadcast
vdat2 = vdat[0]
try:
    vsum = udat - vdat2
except:
    markError('Broadcast')

d.close()
f.close()

reportError()
示例#2
0
xtr.shape = (4,6)
xtr1 = MV2.transpose(xtr)
xtr2 = MV2.transpose(MV2.TransientVariable(xtr))
if not xtr2.shape == (6,4): markError('transpose shape')
xtr3 = numpy.transpose(xtr)
if not MV2.allclose(xtr1, xtr3): markError('transpose 2')
if not MV2.allclose(xtr2, xtr3): markError('transpose 1')

## where(condition, x, y) 
##   where(condition, x, y) is x where condition is true, y otherwise
xwhere = MV2.where(MV2.greater(xouter,200),xouter,MV2.masked)
xwhere2 = MV2.where(MV2.greater(ud,200),ud,MV2.masked)
xwhere3 = MV2.where(MV2.greater(uf,200),uf,MV2.masked)
xwhere2 = MV2.choose(MV2.greater(xouter,200), (MV2.masked, xouter))
if not MV2.allclose(xwhere,xwhere2): markError('where test 1')

## diagonal(x, k)
xdiag = MV2.TransientVariable([[1,2,3],[4,5,6]])
if not MV2.allclose(MV2.diagonal(xdiag, 1), [2,6]): markError('diagonal')
# Broadcast
vdat2 = vdat[0]
try:
    vsum = udat - vdat2
except:
    markError('Broadcast')

d.close()
f.close()

reportError()
示例#3
0
文件: test_mv2.py 项目: zshaheen/cdms
 def testDiagnoal(self):
     xdiag = MV2.TransientVariable([[1, 2, 3], [4, 5, 6]])
     self.assertTrue(MV2.allclose(MV2.diagonal(xdiag, 1), [2, 6]))
示例#4
0
xtr3 = numpy.transpose(xtr)
if not MV2.allclose(xtr1, xtr3):
    markError("transpose 2")
if not MV2.allclose(xtr2, xtr3):
    markError("transpose 1")

## where(condition, x, y)
##   where(condition, x, y) is x where condition is true, y otherwise
xwhere = MV2.where(MV2.greater(xouter, 200), xouter, MV2.masked)
xwhere2 = MV2.where(MV2.greater(ud, 200), ud, MV2.masked)
xwhere3 = MV2.where(MV2.greater(uf, 200), uf, MV2.masked)
xwhere2 = MV2.choose(MV2.greater(xouter, 200), (MV2.masked, xouter))
if not MV2.allclose(xwhere, xwhere2):
    markError("where test 1")

## diagonal(x, k)
xdiag = MV2.TransientVariable([[1, 2, 3], [4, 5, 6]])
if not MV2.allclose(MV2.diagonal(xdiag, 1), [2, 6]):
    markError("diagonal")
# Broadcast
vdat2 = vdat[0]
try:
    vsum = udat - vdat2
except:
    markError("Broadcast")

d.close()
f.close()

reportError()