Author: Brian Kearns <[email protected]>
Branch:
Changeset: r70297:bf6bb7bf1035
Date: 2014-03-26 13:52 -0400
http://bitbucket.org/pypy/pypy/changeset/bf6bb7bf1035/
Log: fix np.empty_like(dtype=None) not copying dtype (issue1715)
diff --git a/pypy/module/micronumpy/ctors.py b/pypy/module/micronumpy/ctors.py
--- a/pypy/module/micronumpy/ctors.py
+++ b/pypy/module/micronumpy/ctors.py
@@ -100,7 +100,7 @@
@unwrap_spec(subok=bool)
def empty_like(space, w_a, w_dtype=None, w_order=None, subok=True):
w_a = convert_to_array(space, w_a)
- if w_dtype is None:
+ if space.is_none(w_dtype):
dtype = w_a.get_dtype()
else:
dtype = space.interp_w(descriptor.W_Dtype,
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
@@ -404,6 +404,8 @@
assert b.shape == a.shape
assert b.dtype == a.dtype
assert b[0,0] != 1
+ b = np.empty_like(np.array(True), dtype=None)
+ assert b.dtype is np.dtype(bool)
b = np.empty_like(a, dtype='i4')
assert b.shape == a.shape
assert b.dtype == np.dtype('i4')
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit