Commits

Brian Kearns  committed bf6bb7b

fix np.empty_like(dtype=None) not copying dtype (issue1715)

  • Participants
  • Parent commits ba47143

Comments (0)

Files changed (2)

File pypy/module/micronumpy/ctors.py

 @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,

File pypy/module/micronumpy/test/test_ndarray.py

         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')