Author: Brian Kearns <[email protected]>
Branch:
Changeset: r67662:840fdf1b5dac
Date: 2013-10-28 15:31 -0400
http://bitbucket.org/pypy/pypy/changeset/840fdf1b5dac/
Log: be more strict about scalar any/all return types
diff --git a/pypy/module/micronumpy/interp_boxes.py
b/pypy/module/micronumpy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/micronumpy/interp_boxes.py
@@ -229,12 +229,14 @@
return space.newtuple([w_quotient, w_remainder])
def descr_any(self, space):
+ from pypy.module.micronumpy.interp_dtype import get_dtype_cache
value = space.is_true(self)
- return self.get_dtype(space).box(value)
+ return get_dtype_cache(space).w_booldtype.box(value)
def descr_all(self, space):
+ from pypy.module.micronumpy.interp_dtype import get_dtype_cache
value = space.is_true(self)
- return self.get_dtype(space).box(value)
+ return get_dtype_cache(space).w_booldtype.box(value)
def descr_ravel(self, space):
from pypy.module.micronumpy.base import convert_to_array
diff --git a/pypy/module/micronumpy/test/test_dtypes.py
b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -740,35 +740,25 @@
def test_any_all_nonzero(self):
import numpypy as numpy
x = numpy.bool_(True)
- assert x.any()
- assert x.all()
- assert x.__nonzero__()
- assert isinstance(x.any(), numpy.bool_)
- assert isinstance(x.__nonzero__(), bool)
+ assert x.any() is numpy.True_
+ assert x.all() is numpy.True_
+ assert x.__nonzero__() is True
x = numpy.bool_(False)
- assert not x.any()
- assert not x.all()
- assert not x.__nonzero__()
- assert isinstance(x.any(), numpy.bool_)
- assert isinstance(x.__nonzero__(), bool)
+ assert x.any() is numpy.False_
+ assert x.all() is numpy.False_
+ assert x.__nonzero__() is False
x = numpy.float64(0)
- assert not x.any()
- assert not x.all()
- assert not x.__nonzero__()
- assert isinstance(x.any(), numpy.float64)
- assert isinstance(x.__nonzero__(), bool)
+ assert x.any() is numpy.False_
+ assert x.all() is numpy.False_
+ assert x.__nonzero__() is False
x = numpy.complex128(0)
- assert not x.any()
- assert not x.all()
- assert not x.__nonzero__()
- assert isinstance(x.any(), numpy.complex128)
- assert isinstance(x.__nonzero__(), bool)
+ assert x.any() is numpy.False_
+ assert x.all() is numpy.False_
+ assert x.__nonzero__() is False
x = numpy.complex128(0+1j)
- assert x.any()
- assert x.all()
- assert x.__nonzero__()
- assert isinstance(x.any(), numpy.complex128)
- assert isinstance(x.__nonzero__(), bool)
+ assert x.any() is numpy.True_
+ assert x.all() is numpy.True_
+ assert x.__nonzero__() is True
def test_ravel(self):
from numpypy import float64, int8, array
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit