[−][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; extern crate numpy; extern crate pyo3; 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 array::get_array_module; |
pub use array::PyArray; |
pub use array::PyArray1; |
pub use array::PyArray2; |
pub use array::PyArray3; |
pub use array::PyArray4; |
pub use array::PyArray5; |
pub use array::PyArray6; |
pub use array::PyArrayDyn; |
pub use convert::IntoPyArray; |
pub use convert::NpyIndex; |
pub use convert::ToNpyDims; |
pub use convert::ToPyArray; |
pub use error::ArrayShape; |
pub use error::ErrorKind; |
pub use error::IntoPyErr; |
pub use error::IntoPyResult; |
pub use npyffi::PY_ARRAY_API; |
pub use npyffi::PY_UFUNC_API; |
pub use types::NpyDataType; |
pub use 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 |