diff options
author | sasha <sasha@localhost> | 2006-01-04 05:53:16 +0000 |
---|---|---|
committer | sasha <sasha@localhost> | 2006-01-04 05:53:16 +0000 |
commit | 3b4ee4f1edad964c20bb9dc7a32cedff4113a5cb (patch) | |
tree | 83ab3d8ecd81e2c6f52ac247ff3f1b93d228bed1 | |
parent | 1c2c47b0cb743f47dcec7d537a99e717096b5007 (diff) | |
download | numpy-3b4ee4f1edad964c20bb9dc7a32cedff4113a5cb.tar.gz |
fixed sf bug 1395646
-rw-r--r-- | scipy/base/ma.py | 4 | ||||
-rw-r--r-- | scipy/base/tests/test_ma.py | 19 |
2 files changed, 20 insertions, 3 deletions
diff --git a/scipy/base/ma.py b/scipy/base/ma.py index a88d3cb4f..245351349 100644 --- a/scipy/base/ma.py +++ b/scipy/base/ma.py @@ -742,14 +742,14 @@ array(data = %(data)s, self.unmask() if self._mask is not None: raise MAError, 'Cannot convert masked element to a Python float.' - return float(self.data[...]) + return float(self.data.item()) def __int__(self): "Convert self to int." self.unmask() if self._mask is not None: raise MAError, 'Cannot convert masked element to a Python int.' - return int(self.data[...]) + return int(self.data.item()) def __getitem__(self, i): "Get item described by i. Not a copy as in previous versions." diff --git a/scipy/base/tests/test_ma.py b/scipy/base/tests/test_ma.py index 02253da6a..884a4a277 100644 --- a/scipy/base/tests/test_ma.py +++ b/scipy/base/tests/test_ma.py @@ -296,6 +296,15 @@ class test_ma(ScipyTestCase): z.put(y) assert eq (x, z) + def check_testMaPut(self): + (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d + m = [1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1] + i = scipy.nonzero(m) + putmask(xm, m, z) + assert take(xm, i) == z + put(ym, i, zm) + assert take(ym, i) == zm + def check_testOddFeatures(self): "Test of other odd features" x = arange(20); x=x.reshape(4,5) @@ -564,7 +573,15 @@ class test_ma(ScipyTestCase): self.failUnless(eq(a2dma, 7./3.)) a2dma = average(a2dm, axis=1) self.failUnless(eq(a2dma, [1.5, 4.0])) - + + def check_testToPython(self): + self.assertEqual(1, int(array(1))) + self.assertEqual(1.0, float(array(1))) + self.assertEqual(1, int(array([[[1]]]))) + self.assertEqual(1.0, float(array([[1]]))) + self.failUnlessRaises(ValueError, float, array([1,1])) + self.failUnlessRaises(MAError, float, array([1],mask=[1])) + def timingTest(): for f in [testf, testinplace]: for n in [1000,10000,50000]: |