On 27/12/18 3:21 am, Benjamin Root wrote:
Ewww, kinda wish that would be an error... It would be too easy for a typo to get accepted this way.

On Wed, Dec 26, 2018 at 1:59 AM Eric Wieser <wieser.eric+nu...@gmail.com <mailto:wieser.eric%2bnu...@gmail.com>> wrote:

    In the latest version of numpy, this runs without an error,
    although may or may not be what you want:

    |In [1]: np.array([[1,2],[[1,2],[3,4]]]) Out[1]: array([[1, 2],
    [list([1, 2]), list([3, 4])]], dtype=object) |

    Here the result is a 2x2 array, where some elements are numbers
    and others are lists.

    ​


Specify the dtype explicitly: `dtype=int` or so, then NumPy will refuse to create a ragged array.


There has been occasional discussion of `dtype='not-object'`, but I don't think it resulted in an issue or PR.

Matti

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion

Reply via email to