You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
remainder is not implemented for timedelta64 #12092
>>> a % b
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: ufunc 'remainder' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
>>> a % 2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: ufunc 'remainder' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
Lately I'm fighting with timestamped data, read via pandas IO. It was not a smooth journey: a lot of bumps on the road, some of which I contributed (at leas so I hope) to mitigate (see pandas-dev/pandas#22802).
My point is that if timedelta64 is not deprecated it should be implemented in a consistent way. Continuously juggling between different representation of the same quantity depending of the operation you are trying to perform is unnerving.
Just if you are interest in the problem that prompted this issue / request for enhancement. I have a signal sampled at 102.4 Hz with a jitter that causes deviations of about ±0.05 Hz. I have timestamps (stored as timedelta64) at 𝘪⋅𝛥𝘵 + 𝜀ᵢ ; the modulo arithmetic here is handy to compute the deviation 𝜀ᵢ of the sampling interval with respect to the nominal one. This is not possible directly: I have to convert first the timedelta64 to long integers and then back to timedelta64. Of course I can circumvent the problem in a lot of ways but it would be nice to this in the natural way:
(𝘪⋅𝛥𝘵 + 𝜀ᵢ) mod 𝛥𝘵
A few of us (including myself) have been slowly improving/fixing datetime64, but it isn't as widely used as most other parts of NumPy. We don't need convincing to add this feature/fix -- rather someone like @tylerjereddy might need convincing to add this himself :).
Let me express my profound gratitude to all numpy contributors, for this invaluable tool. My intention opening this issue was of course only to signal a perceived incongruence in the current datetime64/timedelta64 semantics/arithmetic, not to overburden the maintainers. Let me know If I can help.
Yeah, I'll close this then. I think I may still try to follow up with remainder support for one or two other operand types mixed with timedelta64 and I think Eric suggested divmod would be a reasonable follow-up as well, but that can be pursued elsewhere.
Activity
tylerjereddy commentedon Oct 5, 2018
There hasn't been much movement on
datetime64issues lately; I tried to fix a few things here and there.If this is something that should be fixed, people may need some convincing!
miccoli commentedon Oct 5, 2018
@tylerjereddy
timedelta64is the base for pandas Time Deltas.Lately I'm fighting with timestamped data, read via pandas IO. It was not a smooth journey: a lot of bumps on the road, some of which I contributed (at leas so I hope) to mitigate (see pandas-dev/pandas#22802).
My point is that if
timedelta64is not deprecated it should be implemented in a consistent way. Continuously juggling between different representation of the same quantity depending of the operation you are trying to perform is unnerving.Just if you are interest in the problem that prompted this issue / request for enhancement. I have a signal sampled at 102.4 Hz with a jitter that causes deviations of about ±0.05 Hz. I have timestamps (stored as
timedelta64) at 𝘪⋅𝛥𝘵 + 𝜀ᵢ ; the modulo arithmetic here is handy to compute the deviation 𝜀ᵢ of the sampling interval with respect to the nominal one. This is not possible directly: I have to convert first thetimedelta64to long integers and then back totimedelta64. Of course I can circumvent the problem in a lot of ways but it would be nice to this in the natural way:(𝘪⋅𝛥𝘵 + 𝜀ᵢ) mod 𝛥𝘵
shoyer commentedon Oct 6, 2018
A few of us (including myself) have been slowly improving/fixing datetime64, but it isn't as widely used as most other parts of NumPy. We don't need convincing to add this feature/fix -- rather someone like @tylerjereddy might need convincing to add this himself :).
tylerjereddy commentedon Oct 6, 2018
Ok, I tried to help with #11890, #11873, #11852, #11851, and #11841, which have maybe lingered a bit.
I'll take a look here then
shoyer commentedon Oct 6, 2018
@tylerjereddy feel free to ping me on review for datetime64 issues
miccoli commentedon Oct 6, 2018
a small note:
Let me express my profound gratitude to all numpy contributors, for this invaluable tool. My intention opening this issue was of course only to signal a perceived incongruence in the current datetime64/timedelta64 semantics/arithmetic, not to overburden the maintainers. Let me know If I can help.
miccoli commentedon Oct 31, 2018
I think that #12120 completely addresses the present issue. Can I close the present issue, or there is a reason for keeping it open?
tylerjereddy commentedon Oct 31, 2018
Yeah, I'll close this then. I think I may still try to follow up with remainder support for one or two other operand types mixed with timedelta64 and I think Eric suggested divmod would be a reasonable follow-up as well, but that can be pursued elsewhere.
miccoli commentedon Oct 31, 2018
as what regard
mmoperands,divmodand//should follow, so thatis an invariant.
thnx again.