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

ENH: (NEP 18) implement and test np.in1d and np.interp #398

Merged
merged 2 commits into from Mar 30, 2023

Conversation

neutrinoceros
Copy link
Member

As discussed in #289

@neutrinoceros
Copy link
Member Author

actually, going into draft mode for a minute, while I try to squeeze np.interp in too

@neutrinoceros neutrinoceros changed the title ENH: (NEP 18) implement and test np.in1d ENH: (NEP 18) implement and test np.in1d and np.interp Mar 28, 2023
@neutrinoceros
Copy link
Member Author

did I forget to click the "draft" button ? Anyway, this is ready now

@implements(np.interp)
def interp(x, xp, fp, *args, **kwargs):
_validate_units_consistency((x, xp))
ret_units = getattr(fp, "units", 1)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ret_units = getattr(fp, "units", 1)
ret_units = getattr(fp, "units", NULL_UNIT)

Copy link
Member

Choose a reason for hiding this comment

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

Doesn't really make much difference, the 1 just made me double-take reading this, NULL_UNIT makes the logic clearer.

Copy link
Member Author

Choose a reason for hiding this comment

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

I intentionally didn't use get_units (which is equivalent to your suggestion) because I wanted the output to match fp's type (so a pure ndarray wouldn't leak as a dimensionless unyt_array). I could add a comment to make that intention clearer, or I could just go with your suggestion and change the test too, no strong opinions actually. Your call !

Copy link
Member

Choose a reason for hiding this comment

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

Ah good call please add a comment

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@ngoldbaum ngoldbaum merged commit 1b84388 into yt-project:main Mar 30, 2023
9 checks passed
@neutrinoceros neutrinoceros deleted the nep18_in1d branch March 30, 2023 21:33
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.

None yet

2 participants