diff options
author | Alan McIntyre <alan.mcintyre@local> | 2008-07-22 23:02:29 +0000 |
---|---|---|
committer | Alan McIntyre <alan.mcintyre@local> | 2008-07-22 23:02:29 +0000 |
commit | 681aa536342db1332a5af9b632495ddc883ecba9 (patch) | |
tree | 75fee25252914fcb9a10f465dcd60fc8f2fd33ee /numpy | |
parent | 6dd88dc3b6c94d54585f639c533c00bf0928e13a (diff) | |
download | numpy-681aa536342db1332a5af9b632495ddc883ecba9.tar.gz |
Standardize NumPy import as "import numpy as np".
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/ma/tests/test_subclassing.py | 26 | ||||
-rw-r--r-- | numpy/testing/tests/test_utils.py | 38 |
2 files changed, 32 insertions, 32 deletions
diff --git a/numpy/ma/tests/test_subclassing.py b/numpy/ma/tests/test_subclassing.py index 4d9842506..eff7b268d 100644 --- a/numpy/ma/tests/test_subclassing.py +++ b/numpy/ma/tests/test_subclassing.py @@ -10,25 +10,25 @@ __version__ = '1.0' __revision__ = "$Revision: 3473 $" __date__ = '$Date: 2007-10-29 17:18:13 +0200 (Mon, 29 Oct 2007) $' -import numpy as N +import numpy as np import numpy.core.numeric as numeric from numpy.testing import * from numpy.ma.testutils import * from numpy.ma.core import * -class SubArray(N.ndarray): - """Defines a generic N.ndarray subclass, that stores some metadata +class SubArray(np.ndarray): + """Defines a generic np.ndarray subclass, that stores some metadata in the dictionary `info`.""" def __new__(cls,arr,info={}): - x = N.asanyarray(arr).view(cls) + x = np.asanyarray(arr).view(cls) x.info = info return x def __array_finalize__(self, obj): self.info = getattr(obj,'info',{}) return def __add__(self, other): - result = N.ndarray.__add__(self, other) + result = np.ndarray.__add__(self, other) result.info.update({'added':result.info.pop('added',0)+1}) return result @@ -52,13 +52,13 @@ class MSubArray(SubArray,MaskedArray): msubarray = MSubArray -class MMatrix(MaskedArray, N.matrix,): +class MMatrix(MaskedArray, np.matrix,): def __new__(cls, data, mask=nomask): - mat = N.matrix(data) + mat = np.matrix(data) _data = MaskedArray.__new__(cls, data=mat, mask=mask) return _data def __array_finalize__(self,obj): - N.matrix.__array_finalize__(self, obj) + np.matrix.__array_finalize__(self, obj) MaskedArray.__array_finalize__(self,obj) return def _get_series(self): @@ -74,7 +74,7 @@ class TestSubclassing(TestCase): def test_data_subclassing(self): "Tests whether the subclass is kept." - x = N.arange(5) + x = np.arange(5) m = [0,0,1,0,0] xsub = SubArray(x) xmsub = masked_array(xsub, mask=m) @@ -84,14 +84,14 @@ class TestSubclassing(TestCase): def test_maskedarray_subclassing(self): "Tests subclassing MaskedArray" - x = N.arange(5) + x = np.arange(5) mx = mmatrix(x,mask=[0,1,0,0,0]) - assert isinstance(mx._data, N.matrix) + assert isinstance(mx._data, np.matrix) "Tests masked_unary_operation" assert isinstance(add(mx,mx), mmatrix) assert isinstance(add(mx,x), mmatrix) assert_equal(add(mx,x), mx+x) - assert isinstance(add(mx,mx)._data, N.matrix) + assert isinstance(add(mx,mx)._data, np.matrix) assert isinstance(add.outer(mx,mx), mmatrix) "Tests masked_binary_operation" assert isinstance(hypot(mx,mx), mmatrix) @@ -126,7 +126,7 @@ class TestSubclassing(TestCase): def test_subclasspreservation(self): "Checks that masked_array(...,subok=True) preserves the class." - x = N.arange(5) + x = np.arange(5) m = [0,0,1,0,0] xinfo = [(i,j) for (i,j) in zip(x,m)] xsub = MSubArray(x, mask=m, info={'xsub':xinfo}) diff --git a/numpy/testing/tests/test_utils.py b/numpy/testing/tests/test_utils.py index ea8fa044b..2d42e0a9a 100644 --- a/numpy/testing/tests/test_utils.py +++ b/numpy/testing/tests/test_utils.py @@ -1,4 +1,4 @@ -import numpy as N +import numpy as np from numpy.testing import * import unittest @@ -19,29 +19,29 @@ class _GenericTest(object): def test_array_rank1_eq(self): """Test two equal array of rank 1 are found equal.""" - a = N.array([1, 2]) - b = N.array([1, 2]) + a = np.array([1, 2]) + b = np.array([1, 2]) self._test_equal(a, b) def test_array_rank1_noteq(self): """Test two different array of rank 1 are found not equal.""" - a = N.array([1, 2]) - b = N.array([2, 2]) + a = np.array([1, 2]) + b = np.array([2, 2]) self._test_not_equal(a, b) def test_array_rank2_eq(self): """Test two equal array of rank 2 are found equal.""" - a = N.array([[1, 2], [3, 4]]) - b = N.array([[1, 2], [3, 4]]) + a = np.array([[1, 2], [3, 4]]) + b = np.array([[1, 2], [3, 4]]) self._test_equal(a, b) def test_array_diffshape(self): """Test two arrays with different shapes are found not equal.""" - a = N.array([1, 2]) - b = N.array([[1, 2], [1, 2]]) + a = np.array([1, 2]) + b = np.array([[1, 2], [1, 2]]) self._test_not_equal(a, b) @@ -52,7 +52,7 @@ class TestEqual(_GenericTest, unittest.TestCase): def test_generic_rank1(self): """Test rank 1 array for all dtypes.""" def foo(t): - a = N.empty(2, t) + a = np.empty(2, t) a.fill(1) b = a.copy() c = a.copy() @@ -71,7 +71,7 @@ class TestEqual(_GenericTest, unittest.TestCase): def test_generic_rank3(self): """Test rank 3 array for all dtypes.""" def foo(t): - a = N.empty((4, 2, 3), t) + a = np.empty((4, 2, 3), t) a.fill(1) b = a.copy() c = a.copy() @@ -89,35 +89,35 @@ class TestEqual(_GenericTest, unittest.TestCase): def test_nan_array(self): """Test arrays with nan values in them.""" - a = N.array([1, 2, N.nan]) - b = N.array([1, 2, N.nan]) + a = np.array([1, 2, np.nan]) + b = np.array([1, 2, np.nan]) self._test_equal(a, b) - c = N.array([1, 2, 3]) + c = np.array([1, 2, 3]) self._test_not_equal(c, b) def test_string_arrays(self): """Test two arrays with different shapes are found not equal.""" - a = N.array(['floupi', 'floupa']) - b = N.array(['floupi', 'floupa']) + a = np.array(['floupi', 'floupa']) + b = np.array(['floupi', 'floupa']) self._test_equal(a, b) - c = N.array(['floupipi', 'floupa']) + c = np.array(['floupipi', 'floupa']) self._test_not_equal(c, b) def test_recarrays(self): """Test record arrays.""" - a = N.empty(2, [('floupi', N.float), ('floupa', N.float)]) + a = np.empty(2, [('floupi', np.float), ('floupa', np.float)]) a['floupi'] = [1, 2] a['floupa'] = [1, 2] b = a.copy() self._test_equal(a, b) - c = N.empty(2, [('floupipi', N.float), ('floupa', N.float)]) + c = np.empty(2, [('floupipi', np.float), ('floupa', np.float)]) c['floupipi'] = a['floupi'].copy() c['floupa'] = a['floupa'].copy() |