Skip to content

Commit

Permalink
Fix dtypes tests to work with numpy 1 or 2
Browse files Browse the repository at this point in the history
  • Loading branch information
maffoo committed Sep 24, 2024
1 parent da0807f commit 6013343
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/dtype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ mod tests {

use pyo3::{py_run, types::PyTypeMethods};

use crate::npyffi::NPY_NEEDS_PYAPI;
use crate::npyffi::{is_numpy_2, NPY_NEEDS_PYAPI};

#[test]
fn test_dtype_new() {
Expand Down Expand Up @@ -855,7 +855,11 @@ mod tests {
dtype_bound::<T>(py).typeobj().qualname().unwrap()
}
Python::with_gil(|py| {
assert_eq!(type_name::<bool>(py), "bool_");
if is_numpy_2(py) {
assert_eq!(type_name::<bool>(py), "bool");
} else {
assert_eq!(type_name::<bool>(py), "bool_");
}

assert_eq!(type_name::<i8>(py), "int8");
assert_eq!(type_name::<i16>(py), "int16");
Expand Down

0 comments on commit 6013343

Please sign in to comment.