Live data from Hacker News

DumPy: NumPy except it's OK if you're dum

dynomight.net

31–40 of 62 posts

Re: DumPy: NumPy except it's OK if you're dum

#31

Pretty sure Numpy’s einsum[1] function allows all of this reasoning in vanilla numpy (albeit with a different interface that I assume this author likes less than theirs). Quite sure that first example of how annoying numpy can be could be written much simpler with einsum. [1]: https://numpy.org/doc/stable/reference/generated/numpy.einsu...

How do you invert a matrix with einsum?

Re: DumPy: NumPy except it's OK if you're dum

#32

Earlier quoted context omitted.

There is an "older" discussion with a different title: https://news.ycombinator.com/item?id=43996431 (488 points | 9 days ago | 212 comments)

That's a different post.

You are right. It's a 1 letter difference in the URL and I missed it. Sorry for the noise.

Re: DumPy: NumPy except it's OK if you're dum

#33
post #31

Pretty sure Numpy’s einsum[1] function allows all of this reasoning in vanilla numpy (albeit with a different interface that I assume this author likes less than theirs). Quite sure that first example of how annoying numpy can be could be written much simpler with einsum. [1]: https://numpy.org/doc/stable/reference/generated/numpy.einsu...

How do you invert a matrix with einsum?

Why do you need to invert a matrix?

Re: DumPy: NumPy except it's OK if you're dum

#34

Lots to like here but I'm not so sure about this: > In DumPy, every time you index an array or assign to a dp.Slot, it checks that all indices have been included. Not having to specify all indices makes for more generic implementations. Sure, the broadcasting rules could be simpler and more consistent, but in the meantime (implicit) broadcasting is what makes NumPy so powerful and flexible. Also I think straight up v…

Implicir means write once easy, debug, extend, read hard.

Re: DumPy: NumPy except it's OK if you're dum

#35

I think this sort of DSL construction is a perfect fit for languages with macros: Lisp, Nim, etc. I spend a lot of time on both so I might explore the possibilities. What should a higher-dimensional array indexing, looping, and broadcasting syntax even look like, if until now it's just been cludges? Is it just APL but with actual words?

Author of BQN here, I agree with how section "What about APL?" describes the APL family as not fundamentally better (although details like indexing are often less messy). I outlined a system with lexically-scoped named axes at https://gist.github.com/mlochbaum/401e379ff09d422e2761e16fed... . The linear algebra example would end up something like this:

    solve(X[i,_], Y[j,_], A[i,j,_,_]) = over i, j/+: Y * linalg_solve(A, X)

Re: DumPy: NumPy except it's OK if you're dum

#37

Lots to like here but I'm not so sure about this: > In DumPy, every time you index an array or assign to a dp.Slot, it checks that all indices have been included. Not having to specify all indices makes for more generic implementations. Sure, the broadcasting rules could be simpler and more consistent, but in the meantime (implicit) broadcasting is what makes NumPy so powerful and flexible. Also I think straight up v…

For solo works, the terseness might work, but usually only in short term. Code I wrote 6 months ago looks like someone else's code. For team work, I'd prefer to be explicit if possible. It saves both my teammates' time and my time (when I eventually forget my own code 6 months from now).

Re: DumPy: NumPy except it's OK if you're dum

#38

The kind of person with the background to need these operations, and who is working on the kinds of problems where this stuff comes up, is more than capable of learning numpys syntax. Its not that bad. Avoiding the special purpose tools designed by and used by the people who work on these problems every day is the instinct of someone who has just started needing them and wants to solve new kinds of problems with the…

I agree that this may sometimes be the case, but in this case the author does seem to have very strong points in favor of the proposal. I also think that the accusation of dynomight not understanding NumPy enough is unjustified based on the points given.

Re: DumPy: NumPy except it's OK if you're dum

#39
I think I'll just use Julia, since it has great libraries for doing matrix operations and mapping loops etc onto GPUs and handling indices etc. And if you need some Python library it's easily available using the fantastic PyCall library.

This is a big improvement over numpy, but I don't see much of a compelling reason to go back to Python.

Re: DumPy: NumPy except it's OK if you're dum

#40
post #33
post #31

Earlier quoted context omitted.

How do you invert a matrix with einsum?

Why do you need to invert a matrix?

It's what the "first example of how annoying numpy can be" does, using either np.linalg.solve in a loop or a cursed multidimensional index rearrangement.
Post reply on HN