Skip to content

Conversation

@jbrockmendel
Copy link
Member

@codecov
Copy link

codecov bot commented Feb 23, 2018

Codecov Report

Merging #19870 into master will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@ Coverage Diff @@ ## master #19870 +/- ## ========================================== - Coverage 91.67% 91.66% -0.01%  ========================================== Files 150 150 Lines 48936 48938 +2 ========================================== + Hits 44860 44861 +1  - Misses 4076 4077 +1
Flag Coverage Δ
#multiple 90.04% <ø> (-0.01%) ⬇️
#single 41.81% <ø> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/dtypes/cast.py 87.68% <0%> (-0.3%) ⬇️
pandas/core/ops.py 96.93% <0%> (+0.16%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8f1dfa7...507cb32. Read the comment docs.

------
ValueError
"""
# GH#19388
Copy link
Contributor

Choose a reason for hiding this comment

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

remove the issue number

# GH#19388
if value.dtype == 'm8':
# i.e. has no unit
if util.is_array(value) or (value.view('i8') != NPY_NAT):
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can just do a direct check here

In [1]: np.timedelta64('NaT') Out[1]: numpy.timedelta64('NaT') In [2]: np.timedelta64('NaT') is np.timedelta64(1, 'ns') Out[2]: False In [3]: np.timedelta64('NaT') is np.array([1], dtype='m8[ns]') Out[3]: False 

IOW only if it IS np.timedelta64('NaT') will it be 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.

Doesn't work like pd.NaT:

>>> np.timedelta64('NaT') is np.timedelta64('NaT') False 
divmod(np.array([22, 24]), td)


def test_require_td64_unit():
Copy link
Contributor

Choose a reason for hiding this comment

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

should be in test_constructor

return res


cdef _require_td64_has_unit(value):
Copy link
Contributor

Choose a reason for hiding this comment

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

type value (object) you can also add inline

Parameters
----------
value : np.timedelta64 or ndarray[timedelta64]
Copy link
Contributor

Choose a reason for hiding this comment

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

is this always true?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not quite; good catch.

@jreback jreback added Error Reporting Incorrect or improved errors from pandas Timedelta Timedelta data type labels Feb 24, 2018
ValueError
"""
if value.dtype == 'm8':
# i.e. has no unit
Copy link
Contributor

Choose a reason for hiding this comment

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

pls make this more concise (e.g. a single if)

Copy link
Member Author

Choose a reason for hiding this comment

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

The exception message could be shortened, but everything else is needed. Combining the two ifs into one line would hurt clarity.

Copy link
Contributor

Choose a reason for hiding this comment

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

you can just use missing.is_null_datetimelike instead of repeating code here. pls use a single if.

@jreback jreback added this to the 0.23.0 milestone Feb 26, 2018
ValueError
"""
if value.dtype == 'm8':
# i.e. has no unit
Copy link
Contributor

Choose a reason for hiding this comment

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

you can just use missing.is_null_datetimelike instead of repeating code here. pls use a single if.

@jbrockmendel jbrockmendel deleted the tdfixes7 branch June 22, 2018 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Error Reporting Incorrect or improved errors from pandas Timedelta Timedelta data type

2 participants