summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2007-05-17 11:55:11 +0000
committerTravis Oliphant <oliphant@enthought.com>2007-05-17 11:55:11 +0000
commit4eb3bf56a0d3de3fb67fe6d3fcbd55e798ea4fca (patch)
treec4d260d99374417593a3d39e26fd456b580d48d4 /numpy/core
parent50894958e9a8f515ed85c27127cd91a784eb8308 (diff)
downloadnumpy-4eb3bf56a0d3de3fb67fe6d3fcbd55e798ea4fca.tar.gz
Fix ticekt #511 and start to handle allclose problems.
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/numeric.py18
-rw-r--r--numpy/core/src/arrayobject.c12
2 files changed, 21 insertions, 9 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index b628a858d..0a616582a 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -838,13 +838,17 @@ def allclose(a, b, rtol=1.e-5, atol=1.e-8):
d1 = less_equal(absolute(x-y), atol + rtol * absolute(y))
xinf = isinf(x)
yinf = isinf(y)
- xneg = signbit(x)
- yneg = signbit(y)
- d2 = (xinf == yinf)
- d3 = (xneg == yneg)
- d4 = logical_not(d2)
- return (d1.all() and not d4.any()) or (d2.all() and d3.all())
-
+ if (not xinf.any() and not yinf.any()):
+ return d1.all()
+ d2 = (xinf != yinf)
+ d3 = (x[xinf] == y[yinf])
+ d4 = (~xinf & ~yinf)
+ if d3.size == 0:
+ return False
+ if d3.all():
+ return d1[d4].all()
+ else:
+ return False
def array_equal(a1, a2):
try:
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c
index 200100323..b5b39caad 100644
--- a/numpy/core/src/arrayobject.c
+++ b/numpy/core/src/arrayobject.c
@@ -6918,10 +6918,18 @@ _array_small_type(PyArray_Descr *chktype, PyArray_Descr* mintype)
return mintype;
}
+
if (chktype->type_num > mintype->type_num)
outtype_num = chktype->type_num;
- else
- outtype_num = mintype->type_num;
+ else {
+ if (PyDataType_ISOBJECT(chktype) && \
+ PyDataType_ISSTRING(mintype)) {
+ return PyArray_DescrFromType(NPY_OBJECT);
+ }
+ else {
+ outtype_num = mintype->type_num;
+ }
+ }
save_num = outtype_num;
while(outtype_num < PyArray_NTYPES &&