←back to thread

I don't like NumPy

(dynomight.net)
480 points MinimalAction | 1 comments | | HN request time: 0s | source
Show context
cycomanic ◴[] No.43999427[source]
I sort of agree with the author that N>3 dimensional arrays are cumbersome in numpy, that said I think this is partly because we are really not that great thinking in higher dimensions. I'm interested what the authors solution to the problem is, but unlike the author I'm not a big fan of the eigen notation, but maybe I just don't use it often enough. I don't see the issue with a[:,:,None] notation and that's never given me issues, however I agree about the issue with index arrays. I often make something which think should work and then need to go back to the documentation to realise no that's not how it works.

The inconsistency for argument naming is also annoying (even more if we include scipy), e.g. why is it np.fft.fft(x, axis=1) but np.fft.fftshift(x, axes=1)?!

replies(1): >>44000305 #
bear8642 ◴[] No.44000305[source]
> we are really not that great thinking in higher dimensions.

Normally when you've hit 4d arrays, are you not dealing with a grid of grids?

That is say you've got a 2×3×4×5 array, another way to think about that is you've got a 2×3 matrix of 4×5 matrices. (APL example to show what I mean: https://tryapl.org/?clear&q=%7B%E2%8D%B5%2C%E2%8D%A5%E2%8A%8...)

replies(2): >>44000638 #>>44002019 #
1. thaumasiotes ◴[] No.44002019[source]
> That is say you've got a 2×3×4×5 array, another way to think about that is you've got a 2×3 matrix of 4×5 matrices.

No, a grid of grids is the same thing as a grid.

You can lay out some 4×5 matrices within a 2×3 pattern to have something to look at, but the result is significantly less structured than the 4-dimensional space that the array represents.

    ***** ***** *****
    *A*** ***** *****
    ***** ***** *****
    ***** ***** *****
    
    ***** ***** *****
    ***** ***** *****
    ***** ***** *****
    ***** **B** *****
How close are the points A and B? The taxicab distance is 5.