Incompatible numpy.float64.__round__()
See original GitHub issueround(x)
(i.e. object.__round__(self)
) is expected to return an int
, but for numpy floats, it returns a numpy float.
Issue Analytics
- State:
- Created 10 years ago
- Reactions:1
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Strange behavior of numpy.round - python - Stack Overflow
1 Answer 1 ... For values exactly halfway between rounded decimal values, NumPy rounds to the nearest even value. Thus 1.5 and 2.5...
Read more >Issue 36879: bug with round() and "numpy floats" - Issue Tracker
round() delegates to class.__round__, so what's happening here is that numpy's float implements __round__ in a way it returns a float.
Read more >NumPy 1.20.0 Release Notes
In this case, the Python version float(123) or int(12.) is normally preferable, although the NumPy version may be useful for consistency with NumPy...
Read more >numpy.ndarray.round — NumPy v1.24 Manual
ndarray.round(decimals=0, out=None)#. Return a with each element rounded to the given number of decimals. Refer to numpy.around for full documentation.
Read more >numpy.ndarray.shape — NumPy v1.24 Manual
shape = (-1,) Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: Incompatible shape for in-place modification. Use `.reshape ...
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
Right, I am using Python 3. I did not know that the
round
behavior had changed because I have never been using Python 2.The NumPy floats behave just like ordinary Python floats, until it gets to rounding. This had caused a hard-to-find bug in my project.
We changed float scalar rounding a while ago to align with Python (although not quite sure which NumPy version).