Skip to content

DOC: update np.around docstring with note about floating-point error - #14392

Merged
mattip merged 1 commit into
numpy:masterfrom
ahaldane:around_docstring_inexact
Sep 1, 2019
Merged

mattip merged 1 commit into
numpy:masterfrom
ahaldane:around_docstring_inexact

Conversation

@ahaldane

Copy link
Copy Markdown
Member

Fixes #14391

This just updates the docstring to clarify how this function is inexact for some floating-point values.

(An alternative might be to try to "fix" the np.around algorithm, either by using the BigInt algorithm of the float-printing routines, some simplified bigger-int method, and perhaps also special casing the range of values that are problematic. It's hard to tell how much faster the current algorithm is to a BigInt algorithm, because I find it hard to separate the vectorization speedups in numpy from the round optimizations vs plain python).

Comment thread numpy/core/fromnumeric.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove hyphen in float-printing?

Comment thread numpy/core/fromnumeric.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double backticks for code.

Comment thread numpy/core/fromnumeric.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want double backticks here, the single ticks would try to make a link, which seems redundant.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and some others in this paragraph appear in italics in the rendered doc, they should have double backticks or be fixed to resolve to a link.

Comment thread numpy/core/fromnumeric.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need "::'? I'm a bit concerned that some of these might make it as doctests. Or is that intended? Most doctests are not indented.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to work, see the rendered doc

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: decimals is a parameter, so it only really needs single backticks not double. It is find as code as well, so I am not sure it has to be changed.

Comment thread numpy/core/fromnumeric.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this link to round is correct. @mattip?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rendering of the PR links to the python documentation here

@eric-wieser

Copy link
Copy Markdown
Member

An alternative might be to try to "fix" the np.around algorithm

We should update the docs anyway, then we can leave it in there as a note about how it behaved on older versions if we do eventually fix it.

@ahaldane
ahaldane force-pushed the around_docstring_inexact branch 3 times, most recently from cbdfe46 to c4377c2 Compare August 30, 2019 22:23
@mattip

mattip commented Aug 31, 2019

Copy link
Copy Markdown
Member

LGTM, one small nit about decimals. @charris any more comments?

@charris

charris commented Aug 31, 2019

Copy link
Copy Markdown
Member

@mattip No, I expect you are more familiar with the document markup than I am at this point. You might just go ahead and fix the nit.

@ahaldane
ahaldane force-pushed the around_docstring_inexact branch from c4377c2 to 2ca7ea9 Compare September 1, 2019 00:04
@ahaldane

ahaldane commented Sep 1, 2019

Copy link
Copy Markdown
Member Author

Fixed up the decimals quotes, I think.

@mattip
mattip merged commit 507515e into numpy:master Sep 1, 2019
@mattip

mattip commented Sep 1, 2019

Copy link
Copy Markdown
Member

Thanks @ahaldane it reads well now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

np.around uses an inexact algorithm, not mentioned in docstring

4 participants