Update tests for numpy 2.0 (#4258)
This commit is contained in:
parent
79591f2161
commit
baae9291cc
|
@ -0,0 +1 @@
|
|||
Added support for `bool` conversion with `numpy` 2.0's `numpy.bool` type
|
|
@ -219,6 +219,7 @@ fn impl_py_methods(
|
|||
) -> TokenStream {
|
||||
let Ctx { pyo3_path } = ctx;
|
||||
quote! {
|
||||
#[allow(unknown_lints, non_local_definitions)]
|
||||
impl #pyo3_path::impl_::pyclass::PyMethods<#ty>
|
||||
for #pyo3_path::impl_::pyclass::PyClassImplCollector<#ty>
|
||||
{
|
||||
|
|
|
@ -54,7 +54,11 @@ def test_import_in_subinterpreter_forbidden():
|
|||
def test_type_full_name_includes_module():
|
||||
numpy = pytest.importorskip("numpy")
|
||||
|
||||
assert pyo3_pytests.misc.get_type_full_name(numpy.bool_(True)) == "numpy.bool_"
|
||||
# For numpy 1.x and 2.x
|
||||
assert pyo3_pytests.misc.get_type_full_name(numpy.bool_(True)) in [
|
||||
"numpy.bool",
|
||||
"numpy.bool_",
|
||||
]
|
||||
|
||||
|
||||
def test_accepts_numpy_bool():
|
||||
|
|
|
@ -114,7 +114,7 @@ impl FromPyObject<'_> for bool {
|
|||
if obj
|
||||
.get_type()
|
||||
.name()
|
||||
.map_or(false, |name| name == "numpy.bool_")
|
||||
.map_or(false, |name| name == "numpy.bool_" || name == "numpy.bool")
|
||||
{
|
||||
let missing_conversion = |obj: &Bound<'_, PyAny>| {
|
||||
PyTypeError::new_err(format!(
|
||||
|
|
Loading…
Reference in New Issue