More consistency with array-methods
See original GitHub issueIt’s sometimes hard to tell in numpy whether a given numpy function will also be a method of an array.
e.g. You can go arr.max()
or np.max(arr)
, but you can’s go arr.abs()
(you need to go np.abs(arr)
.
Same goes for most functions: median
, sign
, exp
, etc. It would be nice, because I find it much more readable to look at:
mean_rmse = ((out-targ)**2).mean(axis=1).sqrt().mean(axis=0)
Than:
mean_rmse = np.mean(np.sqrt(np.mean((out-targ)**2, axis =1)), axis=0)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:14 (7 by maintainers)
Top Results From Across the Web
Delicious JavaScript Array Methods
The JavaScript forEach array method is a great way to iterate over each array element without writing your own for loop. While the...
Read more >[JavaScript] Array Methods. With real world examples…
Arrays are convenient when you want your data outputted in a specific order, as objects can output keys and values at random. We...
Read more >Javascript calculate percentage consistency of an array of ...
So for example an array of [1,1,1,1,1] would output 100% consistency, and array of [1,12,23,5,2] would output something like 25% consistency.
Read more >Best Practices in JavaScript Array Iteration | hey it's violet
Learning more about JavaScript Array methods will help you write ... but why not aim for readability, consistency, and flexibility as well?
Read more >Discover JavaScript Arrays & How to Use Them - HubSpot Blog
The JavaScript Array literal looks similar to the constructor method. The most significant difference is the use of bracket notation to create ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m a bit confused at why this is a surprise, given that everyone else commenting in this issue has been talking about why it’s a bad idea and whether there’s any way we can remove methods from ndarray.
Thanks Ralf, the array API standard looks like a great initiative. Though I still after all these years would strongly prefer a method-based syntax, both for readability (avoiding the bracket-matching nightmare discussed at top of post) and ability to re-use code like
And have it be automatically valid in numpy, tensorflow, pytorch, etc. Though it would be nice if there were some “extension function” syntax that would enable us to call this like
x.sigmoid()
.