question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

More consistency with array-methods

See original GitHub issue

It’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:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
njsmithcommented, Jun 29, 2016

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.

0reactions
peteredcommented, Nov 21, 2022

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

def sigmoid(x): 
    return 1/(1+(-x).exp())

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().

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found