[pypy-commit] pypy can_cast: Implement min_dtype() for np.bool_

rlamy noreply at buildbot.pypy.org
Fri May 1 20:05:18 CEST 2015


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: can_cast
Changeset: r76970:c93180802cb1
Date: 2015-05-01 18:30 +0100
http://bitbucket.org/pypy/pypy/changeset/c93180802cb1/

Log:	Implement min_dtype() for np.bool_

diff --git a/pypy/module/micronumpy/test/test_ndarray.py b/pypy/module/micronumpy/test/test_ndarray.py
--- a/pypy/module/micronumpy/test/test_ndarray.py
+++ b/pypy/module/micronumpy/test/test_ndarray.py
@@ -4050,6 +4050,9 @@
 
     def test_can_cast_scalar(self):
         import numpy as np
+        assert np.can_cast(True, np.bool_)
+        assert np.can_cast(True, np.int8)
+        assert not np.can_cast(0, np.bool_)
         assert np.can_cast(127, np.int8)
         assert not np.can_cast(128, np.int8)
         assert np.can_cast(128, np.int16)
diff --git a/pypy/module/micronumpy/types.py b/pypy/module/micronumpy/types.py
--- a/pypy/module/micronumpy/types.py
+++ b/pypy/module/micronumpy/types.py
@@ -2587,3 +2587,7 @@
 
 for Complex_t in complex_types:
     make_complex_min_dtype(Complex_t)
+
+def min_dtype(self):
+    return Bool.num, Bool.num
+Bool.BoxType.min_dtype = min_dtype


More information about the pypy-commit mailing list