question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Memoryview of boolean ndarrays

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
padix-keycommented, Sep 10, 2019

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.12

1reaction
scodercommented, May 19, 2019

Duplicate of #2675.

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found