Add function for comparing buffer_info formats to types

Allows equivalent integral types and numpy dtypes
This commit is contained in:
Patrick Stewart
2016-11-21 17:40:43 +00:00
committed by Wenzel Jakob
parent 5467979588
commit 0b6d08a008
5 changed files with 54 additions and 1 deletions

View File

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