datetime64 arrays don't support buffer protocol
See original GitHub issueIn [4] m = memoryview(np.array(['2001-01-01'], dtype='M8[D]'))
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-4-033a8bae908a> in <module>()
----> 1 m = memoryview(np.array(['2001-01-01'], dtype='M8[D]'))
ValueError: cannot include dtype 'M' in a buffer
Issue Analytics
- State:
- Created 9 years ago
- Reactions:5
- Comments:12 (11 by maintainers)
Top Results From Across the Web
datetime64 arrays don't support buffer protocol - Bountysource
datetime64 arrays don't support buffer protocol. ... In [4] m = memoryview(np.array(['2001-01-01'], dtype='M8[D]')) ...
Read more >How to create of Numpy array of datetime64 objects using C ...
I found a good solution. Here is my function that creates numpy array from a C buffer. PyObject* create_datetime_array(int index, ...
Read more >pybind/Lobby - Gitter
So, yeah, somewhere, the combination of buffer protocol and numpy arrays does not support datetime64, I think. But as you said, you can...
Read more >The array interface protocol — NumPy v1.24 Manual
Cython provides a way to write code that supports the buffer protocol with Python versions older than 2.6 because it has a backward-compatible...
Read more >Release notes — numcodecs 0.10.0a4.dev5+dirty ...
Fix a flatten array error for ZFPY, ZFPY codec is supported on Python 3.9 and 3.10 on ... Handle (new) buffer protocol conforming...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I suspect the problem is at Objects/memoryobject.c:731,
where the return value of PyBuffer_FillInfo is ignored. I’ll submit an upstream issue.
An idea I had about this (which I might have put elsewhere) was to embed numpy type data in the existing buffer spec by exploiting the fact that
T{}
uses no storage space.Which works as
A scarier approach might be to use
pickle.dumps(arr.dtype).encode('hex')
as the field name, to ensure that absolutely any user dtype can be used.