Skip to content

remainder is not implemented for timedelta64 #12092

Closed
@miccoli

Description

@miccoli

timedelta64 allows for multiplication and division, but not for remainder

Reproducing code example:

>>> a = np.timedelta64(7, 's')
>>> b = np.timedelta64(3, 's')
>>> c = np.timedelta64(1, 's')
>>> a == b*2 + c
True
>>> a / 2
numpy.timedelta64(3,'s')
>>> a / b
2.3333333333333335

I would expect that a % b == c and a % 2 == c
but

>>> 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''

Numpy/Python version information:

>>> import sys, numpy; print(numpy.__version__, sys.version)
1.15.2 3.6.5 (default, Apr  6 2018, 12:22:55) 
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions