Macro numpy::pyarray_bound

source ·
macro_rules! pyarray_bound {
    ($py: ident, $([$([$($x:expr),* $(,)*]),+ $(,)*]),+ $(,)*) => { ... };
    ($py: ident, $([$($x:expr),* $(,)*]),+ $(,)*) => { ... };
    ($py: ident, $($x:expr),* $(,)*) => { ... };
}
Expand description

Create a PyArray with one, two or three dimensions.

This macro is backed by ndarray::array.

§Example

use numpy::pyo3::Python;
use numpy::ndarray::array;
use numpy::{pyarray_bound, PyArrayMethods};

Python::with_gil(|py| {
    let array = pyarray_bound![py, [1, 2], [3, 4]];

    assert_eq!(
        array.readonly().as_array(),
        array![[1, 2], [3, 4]]
    );
});