Re: [Numpy-discussion] three-dim array

2018-12-25 Thread Eric Wieser
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

Re: [Numpy-discussion] three-dim array

2018-12-25 Thread Mark Alexander Mikofski
I believe numpy arrays must be rectangular, yours is jagged, instead try >>> x3d = np.array([[[1, 2], [1, 2], [3, 4]]]) >>> x3d.shape (1, 3, 2) Note: 3 opening brackets, yours has 2 And single brackets around the 3 innermost arrays, yours has single brackets for the 1st, and double brackets

[Numpy-discussion] three-dim array

2018-12-25 Thread Jeff
hello, sorry newbe to numpy. I want to define a three-dim array. I know this works: >>> np.array([[[1,2],[3,4]],[[5,6],[7,8]]]) array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]) But can you tell why this doesnt work? >>> np.array([[1,2],[[1,2],[3,4]]]) Traceback (most

Re: [Numpy-discussion] Warn or immidiately change readonly flag on broadcast_arrays return value?

2018-12-25 Thread Marten van Kerkwijk
Hi Juan, I also use `broadcast_to` a lot, to save memory, but definitely have been in a situation where in another piece of code the array is assumed to be normal and writable (typically, that other piece was also written by me; so much for awareness...). Fortunately, `broadcast_to` already

Re: [Numpy-discussion] Warn or immidiately change readonly flag on broadcast_arrays return value?

2018-12-25 Thread Juan Nunez-Iglesias
Probably this will cause a lot of groans, but I've definitely written code modifying `broadcast_to` outputs, intentionally. As such I am -1 on this whole endeavour. My preference on making arrays read-only is to have a very light touch if any. As an example, at some point `np.diag` started

Re: [Numpy-discussion] Warn or immidiately change readonly flag on broadcast_arrays return value?

2018-12-25 Thread Hameer Abbasi
Hi! Broadcasting almost always returns a repeated output (except when all arrays are the same shape), that’s the entire point. I suspect this function is in fairly widespread use and will therefore cause a lot of downstream issues when repeating, so I’m -0.5 on a DeprecationWarning. A

[Numpy-discussion] Warn or immidiately change readonly flag on broadcast_arrays return value?

2018-12-25 Thread Matti Picus
In PR 12609 https://github.com/numpy/numpy/pull/12609 I added code to emit a DepricationWarning when broadcast_arrays returns an array where the output is repeated. While this is a minimal fix to the problem, perhaps we should consider making the output readonly immediately instead? - A