Commits

Brian Kearns  committed caa0da9

fix array init from array scalar

  • Participants
  • Parent commits 45c5e6b

Comments (0)

Files changed (2)

File pypy/module/micronumpy/strides.py

     is_rec_type = dtype is not None and dtype.is_record_type()
     if is_rec_type and is_single_elem(space, w_iterable, is_rec_type):
         return [], [w_iterable]
+    if isinstance(w_iterable, W_NDimArray) and w_iterable.is_scalar():
+        return [], [w_iterable]
     shape = [space.len_w(w_iterable)]
     batch = space.listview(w_iterable)
     while True:

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

         d = c.reshape(3, 4, 0)
         e = d.repeat(3, 0)
         assert e.shape == (9, 4, 0)
+        a = array(123)
+        b = array(a, dtype=float)
+        assert b == 123.0
 
     def test_dtype_attribute(self):
         import numpy as np
         assert ten == 10
 
     def test_empty(self):
-        """
-        Test that empty() works.
-        """
-
         from numpypy import empty
         a = empty(2)
         a[1] = 1.0