mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
Add function for comparing buffer_info formats to types
Allows equivalent integral types and numpy dtypes
This commit is contained in:
committed by
Wenzel Jakob
parent
5467979588
commit
0b6d08a008
@@ -55,7 +55,7 @@ def test_vector_buffer():
|
||||
|
||||
@pytest.requires_numpy
|
||||
def test_vector_buffer_numpy():
|
||||
from pybind11_tests import VectorInt, get_vectorstruct
|
||||
from pybind11_tests import VectorInt, VectorStruct, get_vectorstruct
|
||||
|
||||
a = np.array([1, 2, 3, 4], dtype=np.int32)
|
||||
with pytest.raises(TypeError):
|
||||
@@ -79,6 +79,10 @@ def test_vector_buffer_numpy():
|
||||
m[1]['x'] = 99
|
||||
assert v[1].x == 99
|
||||
|
||||
v = VectorStruct(np.zeros(3, dtype=np.dtype([('w', 'bool'), ('x', 'I'),
|
||||
('y', 'float64'), ('z', 'bool')], align=True)))
|
||||
assert len(v) == 3
|
||||
|
||||
|
||||
def test_vector_custom():
|
||||
from pybind11_tests import El, VectorEl, VectorVectorEl
|
||||
|
||||
Reference in New Issue
Block a user