8000 ENH: support np.datetime64 in linspace · Issue #10514 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
ENH: support np.datetime64 in linspace #10514
Open
@astrofrog

Description

@astrofrog

Currently, np.linspace doesn't work when given np.datetime64 objects:

In [3]: d1 = np.datetime64(100, 'D')

In [4]: d2 = np.datetime64(200, 'D')

In [5]: d = np.linspace(d1, d2, 10)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-a6c4f52b0799> in <module>()
----> 1 d = np.linspace(d1, d2, 10)

~/tmp/numpy/numpy/core/function_base.py in linspace(start, stop, num, endpoint, retstep, dtype)
    106     # Convert float/complex array scalars to float, gh-3504
    107     # and make sure one can use variables that have an __array_interface__, gh-6634
--> 108     start = asanyarray(start) * 1.0
    109     stop  = asanyarray(stop)  * 1.0
    110 

TypeError: ufunc multiply cannot use operands with types dtype('<M8[D]') and dtype('float64')

It would be nice for this to work out of the box.

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

      0