[Numpy-discussion] Re: advice for using datetime64 in C binding

2022-02-18 Thread Benoit Gschwind
Thank you for fixing my code ! :) On Fri, 2022-02-18 at 09:00 -0600, Sebastian Berg wrote: > On Fri, 2022-02-18 at 15:53 +0100, Benoit Gschwind wrote: > > Hello, > > > > I found my ankser in own code ^^ > > > > static PyArray_Descr * create_datetime64_ms_dtype() > > { > > // Extrapolate

[Numpy-discussion] Re: advice for using datetime64 in C binding

2022-02-18 Thread Sebastian Berg
On Fri, 2022-02-18 at 15:53 +0100, Benoit Gschwind wrote: > Hello, > > I found my ankser in own code ^^ > > static PyArray_Descr * create_datetime64_ms_dtype() > { > // Extrapolated from numpy sources > PyArray_Descr * dtype = PyArray_DescrFromType(NPY_DATETIME); > reinter

[Numpy-discussion] Re: advice for using datetime64 in C binding

2022-02-18 Thread Benoit Gschwind
Hello, I found my ankser in own code ^^ static PyArray_Descr * create_datetime64_ms_dtype() { // Extrapolated from numpy sources PyArray_Descr * dtype = PyArray_DescrFromType(NPY_DATETIME); reinterpret_cast(dtype->c_metadata)->meta.base = NPY_FR_ms; return dtype; }

[Numpy-discussion] Re: advice for using datetime64 in C binding

2022-01-20 Thread Benoit Gschwind
Hello, How can I create np.dtype("datetime64[ms]") in C to get the coresponding PyArray_Descr ? Thank you by advance On Wed, 2022-01-19 at 10:08 +0100, Benoit Gschwind wrote: > Hello Sebastian, > > Thanks for the precision > > Best regards > > On Tue, 2022-01-18 at 11:52 -0600, Sebastian Ber

[Numpy-discussion] Re: advice for using datetime64 in C binding

2022-01-19 Thread Benoit Gschwind
Hello Sebastian, Thanks for the precision Best regards On Tue, 2022-01-18 at 11:52 -0600, Sebastian Berg wrote: > On Tue, 2022-01-18 at 18:29 +0100, Benoit Gschwind wrote: > > Hello Sebastian, > > > > Thanks for detail. > > > > The last call has the NPY_ARRAY_C_CONTIGUOUS and NPY_ARRAY_ALIGNE

[Numpy-discussion] Re: advice for using datetime64 in C binding

2022-01-18 Thread Sebastian Berg
On Tue, 2022-01-18 at 18:29 +0100, Benoit Gschwind wrote: > Hello Sebastian, > > Thanks for detail. > > The last call has the NPY_ARRAY_C_CONTIGUOUS and NPY_ARRAY_ALIGNED, > thus I guess it can be no-op most of the time but for some unknown > case > it's may be safer ? Ah, yes, you are right, an

[Numpy-discussion] Re: advice for using datetime64 in C binding

2022-01-18 Thread Benoit Gschwind
Hello Sebastian, Thanks for detail. The last call has the NPY_ARRAY_C_CONTIGUOUS and NPY_ARRAY_ALIGNED, thus I guess it can be no-op most of the time but for some unknown case it's may be safer ? Best regards On Tue, 2022-01-18 at 09:22 -0600, Sebastian Berg wrote: > On Tue, 2022-01-18 at 14:56

[Numpy-discussion] Re: advice for using datetime64 in C binding

2022-01-18 Thread Sebastian Berg
On Tue, 2022-01-18 at 14:56 +0100, Benoit Gschwind wrote: > Hello, > > I using the following code: > > if (PyArray_TYPE(arr1) == NPY_DATETIME) { > // Ensure datetime64[ms] > auto tmp = > reinterpret_cast(PyObject_CallMethod(reinterpret_cast > (arr1), "astype", "(s)", "datetime64[m