summaryrefslogtreecommitdiff
path: root/numpy/core/numeric.py
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-08-10 11:55:33 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-08-10 11:55:33 +0000
commitb772c977e5d4d71c78919ef941858ad438ee4986 (patch)
tree2fbce2c189b29ec2f1deb33e820e70ba3ad56ff8 /numpy/core/numeric.py
parent4b1569e2208baf36a5ebd0de0877946bd86b2a38 (diff)
downloadnumpy-b772c977e5d4d71c78919ef941858ad438ee4986.tar.gz
Update C-API to add features needed for numarray compatibility. Output argument added for several functions and clipmode argument added for a few others.
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r--numpy/core/numeric.py32
1 files changed, 30 insertions, 2 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index 36dcb0ab6..d4537f435 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -11,14 +11,15 @@ __all__ = ['newaxis', 'ndarray', 'flatiter', 'ufunc',
'array2string', 'get_printoptions', 'set_printoptions',
'array_repr', 'array_str', 'set_string_function',
'little_endian', 'require',
- 'fromiter',
+ 'fromiter', 'array_equal', 'array_equiv',
'indices', 'fromfunction',
'load', 'loads', 'isscalar', 'binary_repr', 'base_repr',
'ones', 'identity', 'allclose',
'seterr', 'geterr', 'setbufsize', 'getbufsize',
'seterrcall', 'geterrcall', 'flatnonzero',
'Inf', 'inf', 'infty', 'Infinity',
- 'nan', 'NaN', 'False_', 'True_', 'bitwise_not']
+ 'nan', 'NaN', 'False_', 'True_', 'bitwise_not',
+ 'CLIP', 'RAISE', 'WRAP', 'MAXDIMS', 'BUFSIZE', 'ALLOW_THREADS']
import sys
import multiarray
@@ -29,6 +30,14 @@ from numerictypes import *
bitwise_not = invert
+CLIP = multiarray.CLIP
+WRAP = multiarray.WRAP
+RAISE = multiarray.RAISE
+MAXDIMS = multiarray.MAXDIMS
+ALLOW_THREADS = multiarray.ALLOW_THREADS
+BUFSIZE = multiarray.BUFSIZE
+
+
# from Fernando Perez's IPython
def zeros_like(a):
"""Return an array of zeros of the shape and typecode of a.
@@ -475,6 +484,25 @@ def allclose (a, b, rtol=1.e-5, atol=1.e-8):
return d.ravel().all()
+def array_equal(a1, a2):
+ try:
+ a1, a2 = asarray(a1), asarray(a2)
+ except:
+ return 0
+ if a1.shape != a2.shape:
+ return 0
+ return logical_and.reduce(equal(a1,a2).ravel())
+
+def array_equiv(a1, a2):
+ try:
+ a1, a2 = asarray(a1), asarray(a2)
+ except:
+ return 0
+ try:
+ return logical_and.reduce(equal(a1,a2).ravel())
+ except ValueError:
+ return 0
+
_errdict = {"ignore":ERR_IGNORE,
"warn":ERR_WARN,