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

Handle NaT types in isfinite utility #2716

Merged
merged 1 commit into from May 24, 2018
Merged

Handle NaT types in isfinite utility #2716

merged 1 commit into from May 24, 2018

Conversation

philippjfr
Copy link
Member

As mentioned in #2715 we currently do not handle NaT types at all. Unfortunately this is a bit of a pain since it has only been consistently supported in NumPy >= 1.13. Additionally this PR improves the isfinite utility to work correctly on various arraylike types including pandas index and series types.

return np.isnat(val)
else:
return val.view('i8') == nat_as_integer
elif pd and val is pd.NaT:
Copy link
Member

Choose a reason for hiding this comment

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

Has pd.NaT always been available, or only since a certain Pandas release? If the latter, is that Pandas release a minimum requirement for HoloViews?

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 see StackOverFlow issues about pd.NaT going back to 2014, so that doesn't seem a major worry.

Copy link
Member

Choose a reason for hiding this comment

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

Ok.

Copy link
Member Author

Choose a reason for hiding this comment

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

That said we should make a list of optional dependencies and determine minimum versions for them.

elif numpy_version >= '1.13':
return ~np.isnat(val)
else:
return val.view('i8') != nat_as_integer
Copy link
Member

Choose a reason for hiding this comment

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

And this logic can't be folded into isnat above?

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.

Copy link
Member

Choose a reason for hiding this comment

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

Looks good; thanks.

@philippjfr philippjfr force-pushed the isfinite_nat branch 2 times, most recently from 972aa5d to 0267a8d Compare May 22, 2018 23:27
@jlstevens
Copy link
Contributor

Looks good although having to do those version checks for both numpy and pandas is rather annoying. Ready to merge?

@philippjfr
Copy link
Member Author

Yes, would be good to merge now since this is also needed to make #2719 work properly.

@jlstevens
Copy link
Contributor

Merging.

@jlstevens jlstevens merged commit f4355a9 into master May 24, 2018
@philippjfr philippjfr deleted the isfinite_nat branch July 4, 2018 11:13
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

3 participants