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.

ENH: Implement __round__ special method for ndarrays

See original GitHub issue

This would allow calling round(array). While this would certainly be equivalent to np.round(array), a similar feature is already there with abs(array) (which calls __abs__) and np.abs(array).

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:17 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
sebergcommented, Dec 14, 2022

Sounds like we should just start with decimals=None raising an informative error, that way users can use round and get an informative error when that doesn’t work.

It could still be allowed in some future.

0reactions
mhvkcommented, Dec 13, 2022

Partially, this seems to be a question also of whether the current round(numpy_scalar) is desired behaviour. I also do not like scalars and arrays treated differently.

An alternative would be to generalize and have round(array, ndigits=None) cast to int64 (raising or warning on overflow). That would be backwards compatible except in cases like 1e300 where the current answer is already not great.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Circular array - GeeksforGeeks
An array is called circular if we consider the first element as next of the last element. Circular arrays are used to implement...
Read more >
Lodash Documentation
Creates an array of elements split into groups the length of size . If array can't be split ... Note: Unlike _.pullAll ,...
Read more >
Easy Initializing for Records and Arrays - Oracle Blogs
Use the new qualified expressions to create functions when and where you need them.
Read more >
Math.floor() - JavaScript - MDN Web Docs
The Math.floor() function always rounds down and returns the largest integer less than or equal to a given number.
Read more >
Circular Pattern/Array in Blender - EngMorph
The procedure to make Circular Array is explained below: 4. Change pivot point to “3D Curser then Select the Three Vertices and Extrude...
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