ext: Updated Pybind11 to version 2.4.1.
This updates Pybind11 from version 2.2.1 to version 2.4.1. This fixes
warning/error received when "<experiment/optional>" is used when
compiling using c++14 with clang. It should be noted that
"ext/pybind11/include/pybind11/std.h" has been changed to include a fix
added by commit ba42457254. This is
necessary to avoid build errors.
Built: Linux (gcc, c++11) and MacOS (clang, c++14).
Tested: Ran quick tests for X86, ARM, and RISC-V.
Deprecates: https://gem5-review.googlesource.com/c/public/gem5/+/21019
Change-Id: Ie9783511cb6be50136076a55330e645f4f36d075
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21119
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -7,6 +7,21 @@ with pytest.suppress(ImportError):
|
||||
import numpy as np
|
||||
|
||||
|
||||
def test_dtypes():
|
||||
# See issue #1328.
|
||||
# - Platform-dependent sizes.
|
||||
for size_check in m.get_platform_dtype_size_checks():
|
||||
print(size_check)
|
||||
assert size_check.size_cpp == size_check.size_numpy, size_check
|
||||
# - Concrete sizes.
|
||||
for check in m.get_concrete_dtype_checks():
|
||||
print(check)
|
||||
assert check.numpy == check.pybind11, check
|
||||
if check.numpy.num != check.pybind11.num:
|
||||
print("NOTE: typenum mismatch for {}: {} != {}".format(
|
||||
check, check.numpy.num, check.pybind11.num))
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def arr():
|
||||
return np.array([[1, 2, 3], [4, 5, 6]], '=u2')
|
||||
@@ -135,8 +150,18 @@ def test_make_c_f_array():
|
||||
assert not m.make_f_array().flags.c_contiguous
|
||||
|
||||
|
||||
def test_make_empty_shaped_array():
|
||||
m.make_empty_shaped_array()
|
||||
|
||||
# empty shape means numpy scalar, PEP 3118
|
||||
assert m.scalar_int().ndim == 0
|
||||
assert m.scalar_int().shape == ()
|
||||
assert m.scalar_int() == 42
|
||||
|
||||
|
||||
def test_wrap():
|
||||
def assert_references(a, b, base=None):
|
||||
from distutils.version import LooseVersion
|
||||
if base is None:
|
||||
base = a
|
||||
assert a is not b
|
||||
@@ -147,7 +172,10 @@ def test_wrap():
|
||||
assert a.flags.f_contiguous == b.flags.f_contiguous
|
||||
assert a.flags.writeable == b.flags.writeable
|
||||
assert a.flags.aligned == b.flags.aligned
|
||||
assert a.flags.updateifcopy == b.flags.updateifcopy
|
||||
if LooseVersion(np.__version__) >= LooseVersion("1.14.0"):
|
||||
assert a.flags.writebackifcopy == b.flags.writebackifcopy
|
||||
else:
|
||||
assert a.flags.updateifcopy == b.flags.updateifcopy
|
||||
assert np.all(a == b)
|
||||
assert not b.flags.owndata
|
||||
assert b.base is base
|
||||
@@ -282,17 +310,17 @@ def test_overload_resolution(msg):
|
||||
1. (arg0: numpy.ndarray[int32]) -> str
|
||||
2. (arg0: numpy.ndarray[float64]) -> str
|
||||
|
||||
Invoked with:"""
|
||||
Invoked with: """
|
||||
|
||||
with pytest.raises(TypeError) as excinfo:
|
||||
m.overloaded3(np.array([1], dtype='uintc'))
|
||||
assert msg(excinfo.value) == expected_exc + " array([1], dtype=uint32)"
|
||||
assert msg(excinfo.value) == expected_exc + repr(np.array([1], dtype='uint32'))
|
||||
with pytest.raises(TypeError) as excinfo:
|
||||
m.overloaded3(np.array([1], dtype='float32'))
|
||||
assert msg(excinfo.value) == expected_exc + " array([ 1.], dtype=float32)"
|
||||
assert msg(excinfo.value) == expected_exc + repr(np.array([1.], dtype='float32'))
|
||||
with pytest.raises(TypeError) as excinfo:
|
||||
m.overloaded3(np.array([1], dtype='complex'))
|
||||
assert msg(excinfo.value) == expected_exc + " array([ 1.+0.j])"
|
||||
assert msg(excinfo.value) == expected_exc + repr(np.array([1. + 0.j]))
|
||||
|
||||
# Exact matches:
|
||||
assert m.overloaded4(np.array([1], dtype='double')) == 'double'
|
||||
@@ -400,3 +428,20 @@ def test_array_create_and_resize(msg):
|
||||
a = m.create_and_resize(2)
|
||||
assert(a.size == 4)
|
||||
assert(np.all(a == 42.))
|
||||
|
||||
|
||||
@pytest.unsupported_on_py2
|
||||
def test_index_using_ellipsis():
|
||||
a = m.index_using_ellipsis(np.zeros((5, 6, 7)))
|
||||
assert a.shape == (6,)
|
||||
|
||||
|
||||
@pytest.unsupported_on_pypy
|
||||
def test_dtype_refcount_leak():
|
||||
from sys import getrefcount
|
||||
dtype = np.dtype(np.float_)
|
||||
a = np.array([1], dtype=dtype)
|
||||
before = getrefcount(dtype)
|
||||
m.ndim(a)
|
||||
after = getrefcount(dtype)
|
||||
assert after == before
|
||||
|
||||
Reference in New Issue
Block a user