Skip to content

Commit cb16390

Browse files
committed
Add module/crate level docs
1 parent 4daf35c commit cb16390

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

src/convert.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Defines conversion trait between rust types and numpy data types.
2+
13
use ndarray::*;
24
use pyo3::Python;
35

src/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Define Errors
1+
//! Defines error types.
22
33
use pyo3::*;
44
use std::error;

src/lib.rs

+32
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
//! `rust-numpy` provides Rust interfaces for [numpy](http://www.numpy.org/) APIs,
2+
//! especially [ndarray](https://www.numpy.org/devdocs/reference/arrays.ndarray.html) class.
3+
//!
4+
//! It uses [pyo3](https://github.com/PyO3/pyo3) for rust bindings to cpython, and uses
5+
//! [ndarray](https://github.com/bluss/ndarray) for rust side matrix library.
6+
//!
7+
//! For numpy dependency, it calls `import numpy.core` internally so you just need numpy
8+
//! installed by `pip install numpy` or other ways in your python environment.
9+
//! You can use both system environment and `virtualenv`.
10+
//!
11+
//! # Example
12+
//!
13+
//! ```
14+
//! #[macro_use]
15+
//! extern crate ndarray;
16+
//! extern crate numpy;
17+
//! #[macro_use]
18+
//! extern crate pyo3;
19+
//! use pyo3::prelude::*;
20+
//! use numpy::*;
21+
//! fn main() {
22+
//! let gil = Python::acquire_gil();
23+
//! let py = gil.python();
24+
//! let np = PyArrayModule::import(py).unwrap();
25+
//! let py_array = array![[1i64, 2], [3, 4]].into_pyarray(py, &np);
26+
//! assert_eq!(
27+
//! py_array.as_array().unwrap(),
28+
//! array![[1i64, 2], [3, 4]].into_dyn(),
29+
//! );
30+
//! }
31+
//! ```
32+
133
#![feature(specialization)]
234

335
#[macro_use]

src/types.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Implements conversion utitlities.
2+
13
pub use num_complex::Complex32 as c32;
24
pub use num_complex::Complex64 as c64;
35

0 commit comments

Comments
 (0)