Memoryview of boolean ndarrays
See original GitHub issueI would like to create a bint
memoryview of a numpy.ndarray
with dtype=np.bool.
Example:
cimport cython
cimport numpy as np
import numpy as np
cdef np.ndarray array = np.array([True, True, False, True], dtype=np.bool)
cdef bint[:] array_view = array
Unfortunately, running this code raises the following error:
ValueError: Does not understand character buffer dtype format string ('?')
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Boolean numpy arrays with Cython - python - Stack Overflow
How can I store a boolean numpy array using Cython MemoryViews? python · numpy · cython · memoryview · typed-memory-views · Share.
Read more >Typed Memoryviews — Cython 3.0.0a11 documentation
Typed memoryviews allow efficient access to memory buffers, such as those underlying NumPy arrays, without incurring any Python overhead.
Read more >numpy.ndarray.view — NumPy v1.24 Manual
a.view(ndarray_subclass) or a.view(type=ndarray_subclass) just returns an instance of ndarray_subclass that looks at the same array (same shape, dtype, etc.) ...
Read more >Memoryview Benchmarks - Pythonic Perambulations
ndarray type says that the array is contiguous in memory, and C-ordered. For reference, this can be compiled in-place by running python setup.py ......
Read more >Built-in Types — Python 3.11.1 documentation
empty sequences and collections: '' , () , [] , {} , set() , range(0). Operations and built-in functions that have a Boolean...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
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 would like to request to reopen this issue, since #2676 seems not to fix memory views. At least I get still the same runtime error
ValueError: Does not understand character buffer dtype format string ('?')
at Cython 0.29.12Duplicate of #2675.