[−][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 pyo3::prelude::Python; use numpy::{ToPyArray, PyArray}; fn main() { let gil = Python::acquire_gil(); let py = gil.python(); let py_array = array![[1i64, 2], [3, 4]].to_pyarray(py); assert_eq!( py_array.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::error::ErrorKind; |
pub use crate::error::IntoPyErr; |
pub use crate::error::IntoPyResult; |
pub use crate::npyffi::PY_ARRAY_API; |
pub use crate::npyffi::PY_UFUNC_API; |
pub use crate::types::NpyDataType; |
pub use crate::types::TypeNum; |
Modules
array | Safe interface for NumPy ndarray |
convert | Defines conversion traits between rust types and numpy data types. |
error | Defines error types. |
npyffi | Low-Level bindings for NumPy C API. |
types | Implements conversion utitlities. |
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 |
c32 | |
c64 |