<div dir="ltr"><div>Apart from the math-validity discussion, in my experience errors are used a bit too generously in the not-allowed ops. No ops are fine once you learn more about them such as transpose on 1D arrays (good or bad is another discussion). But raising errors bloat the computational code too much. "Is it a scalar oh then do this is it 1D oh make this one is it 2D then do something else." type of coding is really making life difficult.<br></div><div><br></div><div>Most of my time in the numerical code is spent on trying to catch scalars and 1D arrays and writing exceptions because I can't predict what the user would do or what the result should be after certain operations. Quite unwillingly, I've started making everything 2D whether it is required or not because then I can just avoid the following<br></div><div><br></div>np.eye(4)[:, 1]           # 1d<br>np.eye(4)[:, 1:2]         #2d<br>np.eye(4)[:, [1]]         #2d<br>np.eye(4)[:, [1]] @ 5                      # Error<br>np.eye(4)[:, [1]] @ np.array(5)        #Error<br>np.eye(4)[:, [1]] @ np.array([5])      # Result is 1D <br><div>np.eye(4)[:, [1]] @ np.array([[5]])    # Result 2D</div><div><br></div><div>So imagine I'm trying to get a simple multiply_these function, I have already quite some cases to consider such that the function is "Pythonic". If the second argument is int,float do *-mult, if it is a numpy array but has no dimensions then again *-mult but if it is 1d keep dims and also if it is 2d do @-mult. Add broadcasting rules on top of this and it gets a pretty wordy function.Hence, what I would suggest is to also include the use cases while deciding the behavior of a single functionality.<br></div><br><div>So indeed it doesn't make sense to transpose 0d array but as an array object now it would start to have a lot of Wat! moments. <a href="https://www.destroyallsoftware.com/talks/wat">https://www.destroyallsoftware.com/talks/wat</a><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 29, 2018 at 12:51 PM, Andras Deak <span dir="ltr"><<a href="mailto:deak.andris@gmail.com" target="_blank">deak.andris@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Tue, May 29, 2018 at 12:16 PM, Daπid <<a href="mailto:davidmenhur@gmail.com">davidmenhur@gmail.com</a>> wrote:<br>
> Right now, <a href="http://np.int" rel="noreferrer" target="_blank">np.int</a>(8).T throws an error, but np.transpose(<a href="http://np.int" rel="noreferrer" target="_blank">np.int</a>(8)) gives a<br>
> 0-d array. On one hand, it is nice to be able to use the same code for<br>
<br>
</span>`<a href="http://np.int" rel="noreferrer" target="_blank">np.int</a>` is just python `int`! What you mean is `np.int64(8).T` which<br>
works fine, so does `np.array(8).T`.<br>
<div class="HOEnZb"><div class="h5">______________________________<wbr>_________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/numpy-<wbr>discussion</a><br>
</div></div></blockquote></div><br></div>