ext: Update pybind11 to v2.8.1
Change-Id: Ia1c7081377f53fd470addf35526f8b28a949a7b0 Signed-off-by: Jason Lowe-Power <jason@lowepower.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/52523 Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Gabe Black <gabe.black@gmail.com>
This commit is contained in:
committed by
Jason Lowe-Power
parent
ba5f68db3d
commit
1e8aeee698
@@ -2,7 +2,6 @@
|
||||
import pytest
|
||||
|
||||
import env # noqa: F401
|
||||
|
||||
from pybind11_tests import numpy_array as m
|
||||
|
||||
np = pytest.importorskip("numpy")
|
||||
@@ -412,7 +411,7 @@ def test_array_unchecked_fixed_dims(msg):
|
||||
assert m.proxy_auxiliaries2_const_ref(z1)
|
||||
|
||||
|
||||
def test_array_unchecked_dyn_dims(msg):
|
||||
def test_array_unchecked_dyn_dims():
|
||||
z1 = np.array([[1, 2], [3, 4]], dtype="float64")
|
||||
m.proxy_add2_dyn(z1, 10)
|
||||
assert np.all(z1 == [[11, 12], [13, 14]])
|
||||
@@ -445,7 +444,7 @@ def test_initializer_list():
|
||||
assert m.array_initializer_list4().shape == (1, 2, 3, 4)
|
||||
|
||||
|
||||
def test_array_resize(msg):
|
||||
def test_array_resize():
|
||||
a = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9], dtype="float64")
|
||||
m.array_reshape2(a)
|
||||
assert a.size == 9
|
||||
@@ -471,17 +470,70 @@ def test_array_resize(msg):
|
||||
|
||||
|
||||
@pytest.mark.xfail("env.PYPY")
|
||||
def test_array_create_and_resize(msg):
|
||||
def test_array_create_and_resize():
|
||||
a = m.create_and_resize(2)
|
||||
assert a.size == 4
|
||||
assert np.all(a == 42.0)
|
||||
|
||||
|
||||
def test_array_view():
|
||||
a = np.ones(100 * 4).astype("uint8")
|
||||
a_float_view = m.array_view(a, "float32")
|
||||
assert a_float_view.shape == (100 * 1,) # 1 / 4 bytes = 8 / 32
|
||||
|
||||
a_int16_view = m.array_view(a, "int16") # 1 / 2 bytes = 16 / 32
|
||||
assert a_int16_view.shape == (100 * 2,)
|
||||
|
||||
|
||||
def test_array_view_invalid():
|
||||
a = np.ones(100 * 4).astype("uint8")
|
||||
with pytest.raises(TypeError):
|
||||
m.array_view(a, "deadly_dtype")
|
||||
|
||||
|
||||
def test_reshape_initializer_list():
|
||||
a = np.arange(2 * 7 * 3) + 1
|
||||
x = m.reshape_initializer_list(a, 2, 7, 3)
|
||||
assert x.shape == (2, 7, 3)
|
||||
assert list(x[1][4]) == [34, 35, 36]
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
m.reshape_initializer_list(a, 1, 7, 3)
|
||||
assert str(excinfo.value) == "cannot reshape array of size 42 into shape (1,7,3)"
|
||||
|
||||
|
||||
def test_reshape_tuple():
|
||||
a = np.arange(3 * 7 * 2) + 1
|
||||
x = m.reshape_tuple(a, (3, 7, 2))
|
||||
assert x.shape == (3, 7, 2)
|
||||
assert list(x[1][4]) == [23, 24]
|
||||
y = m.reshape_tuple(x, (x.size,))
|
||||
assert y.shape == (42,)
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
m.reshape_tuple(a, (3, 7, 1))
|
||||
assert str(excinfo.value) == "cannot reshape array of size 42 into shape (3,7,1)"
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
m.reshape_tuple(a, ())
|
||||
assert str(excinfo.value) == "cannot reshape array of size 42 into shape ()"
|
||||
|
||||
|
||||
def test_index_using_ellipsis():
|
||||
a = m.index_using_ellipsis(np.zeros((5, 6, 7)))
|
||||
assert a.shape == (6,)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"test_func",
|
||||
[
|
||||
m.test_fmt_desc_float,
|
||||
m.test_fmt_desc_double,
|
||||
m.test_fmt_desc_const_float,
|
||||
m.test_fmt_desc_const_double,
|
||||
],
|
||||
)
|
||||
def test_format_descriptors_for_floating_point_types(test_func):
|
||||
assert "numpy.ndarray[numpy.float" in test_func.__doc__
|
||||
|
||||
|
||||
@pytest.mark.parametrize("forcecast", [False, True])
|
||||
@pytest.mark.parametrize("contiguity", [None, "C", "F"])
|
||||
@pytest.mark.parametrize("noconvert", [False, True])
|
||||
|
||||
Reference in New Issue
Block a user