Hacker News new | ask | show | jobs
by mFixman 737 days ago
Most of the bugs I got on numpy programs came from a variable with a different ndims as expected being broadcast implicitly.

Implicit type casting is considered a mistake in most programming languages; if I were to redesign numpy from scratch I would make all broadcasting explicit.

My solution to these problems is asserting an array's shape often. Does anybody know is there's a tool like mypy or valgrind, but that checks mismatched array shapes rather than types or memory leaks?

1 comments

numpy's API was carefully designed to match matlab, where most of its early users came from.
Then we are lucky they didn't decide to start their arrays at 1 :-)
indeed...