[][src]Crate numpy

rust-numpy provides Rust interfaces for NumPy C APIs, especially for ndarray class.

It uses pyo3 for rust bindings to cpython, and uses ndarray for rust side matrix library.

For numpy dependency, it calls import numpy.core internally. So you just need numpy installed by pip install numpy or other ways in your python environment. You can use both system environment and virtualenv.

This library loads numpy module automatically. So if numpy is not installed, it simply panics, instead of returing a result.

Example

#[macro_use]
extern crate ndarray;
use numpy::{ToPyArray, PyArray};
fn main() {
    pyo3::Python::with_gil(|py| {
        let py_array = array![[1i64, 2], [3, 4]].to_pyarray(py);
        assert_eq!(
            py_array.readonly().as_array(),
            array![[1i64, 2], [3, 4]]
        );
    })
}

Re-exports

pub use crate::array::get_array_module;
pub use crate::array::PyArray;
pub use crate::array::PyArray1;
pub use crate::array::PyArray2;
pub use crate::array::PyArray3;
pub use crate::array::PyArray4;
pub use crate::array::PyArray5;
pub use crate::array::PyArray6;
pub use crate::array::PyArrayDyn;
pub use crate::convert::IntoPyArray;
pub use crate::convert::NpyIndex;
pub use crate::convert::ToNpyDims;
pub use crate::convert::ToPyArray;
pub use crate::npyffi::PY_ARRAY_API;
pub use crate::npyffi::PY_UFUNC_API;
pub use crate::npyiter::NpyIterFlag;
pub use crate::npyiter::NpyMultiIter;
pub use crate::npyiter::NpyMultiIterBuilder;
pub use crate::npyiter::NpySingleIter;
pub use crate::npyiter::NpySingleIterBuilder;

Modules

array

Safe interface for NumPy ndarray

convert

Defines conversion traits between rust types and numpy data types.

npyffi

Low-Level bindings for NumPy C API.

npyiter

Wrapper of Array Iterator API.

Structs

FromVecError

Represents that given vec cannot be treated as array.

NotContiguousError

Represents that the array is not contiguous.

PyArrayDescr

Binding of numpy.dtype.

PyReadonlyArray

Readonly reference of PyArray.

ShapeError

Represents that shapes of the given arrays don't match.

Enums

DataType

Represents numpy data type.

Traits

Element

Represents that a type can be an element of PyArray.

IterMode

Iterator mode for single iterator

Functions

Ix1

Create a one-dimensional index

Ix2

Create a two-dimensional index

Ix3

Create a three-dimensional index

Ix4

Create a four-dimensional index

Ix5

Create a five-dimensional index

Ix6

Create a six-dimensional index

IxDyn

Create a dynamic-dimensional index

Type Definitions

Ix1

one-dimensional

Ix2

two-dimensional

Ix3

three-dimensional

Ix4

four-dimensional

Ix5

five-dimensional

Ix6

six-dimensional

IxDyn

dynamic-dimensional

PyReadonlyArray1

One-dimensional readonly array.

PyReadonlyArray2

Two-dimensional readonly array.

PyReadonlyArray3

Three-dimensional readonly array.

PyReadonlyArray4

Four-dimensional readonly array.

PyReadonlyArray5

Five-dimensional readonly array.

PyReadonlyArray6

Six-dimensional readonly array.

PyReadonlyArrayDyn

Dynamic-dimensional readonly array.

c32
c64