Skip to content

BUG: lib: Fix handling of integer arrays by gradient. - #15212

Merged
mattip merged 1 commit into
numpy:masterfrom
WarrenWeckesser:gradient
Jan 3, 2020
Merged

mattip merged 1 commit into
numpy:masterfrom
WarrenWeckesser:gradient

Conversation

@WarrenWeckesser

Copy link
Copy Markdown
Member

In numpy.gradient, convert integer array inputs to float64 to avoid
unwanted modular arithmetic.

Closes gh-15207.

Comment thread numpy/lib/tests/test_function_base.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.

is there a reason to limit this to only these dtypes? Perhaps it should be testing as many as possible (not datetime64 or object)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I pushed an update with more thorough tests for the integer types.

@mattip

mattip commented Dec 31, 2019

Copy link
Copy Markdown
Member

LGTM. May be a candidate for a wider set of dtypes for both the new tests

@eric-wieser eric-wieser left a comment

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.

See above, this has a behavior change on subclasses, I think

Comment thread numpy/lib/function_base.py Resolved
Comment thread numpy/lib/function_base.py Resolved
In numpy.gradient, convert integer array inputs to float64 to avoid
unwanted modular arithmetic.

Closes numpygh-15207.
@charris

charris commented Jan 2, 2020

Copy link
Copy Markdown
Member

@WarrenWeckesser Did you intend to close this?

@WarrenWeckesser

Copy link
Copy Markdown
Member Author

@charris, yes, after pushing a whitespace change, some Azure Windows tests again failed to install mingw, so I closed and reopened to rerun the tests. I won't bother rerunning this time if those tests fail again.

@WarrenWeckesser

Copy link
Copy Markdown
Member Author

@eric-wieser, I think my updates addressed your requested changes. Let me know if there is anything else that should be changed.

@mattip
mattip merged commit f30b256 into numpy:master Jan 3, 2020
@mattip

mattip commented Jan 3, 2020

Copy link
Copy Markdown
Member

Thanks @WarrenWeckesser

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.

Wrong gradient values for unsigned int data

4 participants