-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: use more generic type inference for fast plotting #15094
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
Conversation
Current coverage is 84.75% (diff: 90.90%)@@ master #15094 diff @@
==========================================
Files 145 145
Lines 51232 51234 +2
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 43420 43423 +3
+ Misses 7812 7811 -1
Partials 0 0
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
Forgot to look at the 'allowed failures' ..
@@ -172,7 +172,7 @@ def _dt_to_float_ordinal(dt): | |||
is a :func:`float`. | |||
""" | |||
if (isinstance(dt, (np.ndarray, Index, Series) | |||
) and is_datetime64_ns_dtype(dt)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theoretically, this is not fully correct, as is_datetime64_any_dtype
can also accept datetime64 values with other than ns resolution?
Although I don't think you can end up here with such values when going through the DatetimeConverter, as datetime64 arrays first get passed through to_datetime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could maybe add a test for this (and for tz aware Timestamp): https://github.com/pandas-dev/pandas/blob/master/pandas/tseries/tests/test_converter.py#L58
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, we already have this:
rs = self.dtc.convert(np.array([
np_datetime64_compat('2012-01-01 00:00:00+0000'),
np_datetime64_compat('2012-01-02 00:00:00+0000')]), None, None)
self.assertEqual(rs[0], xp)
does already test this as the above has [s] resolution, not [ns] .
Would just add a test case for the tz case.
ok, I fixed |
ok, this is actually a tiny public API change, but it was inconsistent / wrong before. |
How safe is it to change this? Couldn't there be places in our code where Just as overview, is this correct?
The combination missing is "ns resolution, no tz (pure numpy)", which is actually what |
self.assertEqual(rs[1], xp) | ||
|
||
rs = self.dtc.convert(ts, None, None) | ||
self.assertEqual(rs, xp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems duplicate of line 71-72 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add similar test for Index([ts - Day(1), ts]).to_pydatetime
to test tz aware datetime.datetime objects (as this is actually what was raising the tests I think, as _mpl_repr()
does return that).
self.assertTrue(is_datetime64_any_dtype('datetime64[ns]')) | ||
self.assertTrue(is_datetime64_any_dtype(ts)) | ||
self.assertTrue(is_datetime64_any_dtype(tsa)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you do the exact same 4 tests for is_datetime64tz_dtype
?
these functions are a bit redundant; the |
Indeed, my search says that |
@jorisvandenbossche yeah I'd leave them for now, they are useful, even if not used :> pushing in a sec |
yes! |
xref #15073
https://travis-ci.org/pandas-dev/pandas/jobs/190356982
was failing on tz-aware dtypes. these routines are the same in that they require datetime64ns (but any also accepts tz-aware).