Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimplement cumulative product NumPy functions #940

Merged
merged 3 commits into from
Dec 20, 2019
Merged

Conversation

jthielen
Copy link
Contributor

This PR resolves two issues from #905 that were identified in #939:

First, convert_arg in numpy_func.py presumes pre_calc_units is a Unit or None, but there are instances where it was passed a string by way of inputs_units in implement_func. Now, any inputs_units as a string are converted to a Unit before being passed to convert_to_consistent_units.

Second, the cumulative product functions were using implement_func with input_units set to something other than None, which was incorrect, since these functions have arguments that should not have units (namely axis). These functions have been reimplemented accordingly.

@hgrecco
Copy link
Owner

hgrecco commented Dec 19, 2019

Could you document the possible values for inputs_units?

@hgrecco
Copy link
Owner

hgrecco commented Dec 20, 2019

bors r+

bors bot added a commit that referenced this pull request Dec 20, 2019
940: Reimplement cumulative product NumPy functions r=hgrecco a=jthielen

This PR resolves two issues from #905 that were identified in #939:

First, `convert_arg` in `numpy_func.py` presumes `pre_calc_units` is a `Unit` or `None`, but there are instances where it was passed a string by way of `inputs_units` in `implement_func`. Now, any `inputs_units` as a string are converted to a `Unit` before being passed to `convert_to_consistent_units`.

Second, the cumulative product functions were using `implement_func` with `input_units` set to something other than `None`, which was incorrect, since these functions have arguments that should not have units (namely `axis`). These functions have been reimplemented accordingly.

- [x] Closes #939 
- [x] Executed ``black -t py36 . && isort -rc . && flake8`` with no errors
- [x] The change is fully covered by automated unit tests
- ~~Documented in docs/ as appropriate~~
- ~~Added an entry to the CHANGES file~~ (fixup to previous change: #905)


Co-authored-by: Jon Thielen <[email protected]>
@bors
Copy link
Contributor

bors bot commented Dec 20, 2019

Build succeeded

@bors bors bot merged commit 0d6a436 into hgrecco:master Dec 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

array function implementation for np.cumprod / np.nancumprod fails with axis
2 participants