@@ -23,43 +23,46 @@ use types::{NpyDataType, TypeNum};
2323/// - Case1: Constructed via [`IntoPyArray`](../convert/trait.IntoPyArray.html) or
2424/// [`from_vec`](#method.from_vec) or [`from_owned_array`](#method.from_owned_vec).
2525///
26- /// These methods don't allocate and use `Box<[T]>` as a internal buffer.
26+ /// These methods don't allocate memory and use `Box<[T]>` as a internal buffer.
2727///
2828/// Please take care that **you cannot use some destructive methods like `resize`,
2929/// for this kind of array**.
3030///
3131/// - Case2: Constructed via other methods, like [`ToPyArray`](../convert/trait.ToPyArray.html) or
3232/// [`from_slice`](#method.from_slice) or [`from_array`](#from_array).
3333///
34- /// These methods allocate a memory area in Python's private heap.
34+ /// These methods allocate memory in Python's private heap.
3535///
36- /// In both cases, **an internal buffer of ` PyArray` is managed by Python GC.**
36+ /// In both cases, **PyArray is managed by Python GC.**
3737/// So you can neither retrieve it nor deallocate it manually.
3838///
3939/// # Reference
4040///
41- /// Like [`new`](#method.new), most constractor methods of this type returns `&PyArray`.
41+ /// Like [`new`](#method.new), all constractor methods of `PyArray` returns `&PyArray`.
4242///
43- /// See [pyo3's document](https://pyo3.rs/master/doc/pyo3/index.html#ownership-and-lifetimes)
44- /// for the reason .
43+ /// This design follows
44+ /// [pyo3's ownership concept](https://pyo3.rs/master/doc/pyo3/index.html#ownership-and-lifetimes) .
4545///
4646///
47- /// # Dimension
48- /// `PyArray` has 2 type parametes `T` and `D`. `T` represents its data type like `f32`, and `D`
49- /// represents its dimension.
47+ /// # Data type and Dimension
48+ /// `PyArray` has 2 type parametes `T` and `D`. `T` represents its data type like
49+ /// [`f32`](https://doc.rust-lang.org/std/primitive.f32.html), and `D` represents its dimension.
5050///
51- /// To specify the dimension, you can use types which implements
52- /// [Dimension](https://docs.rs/ndarray/0.12/ndarray/trait.Dimension.html).
51+ /// All data types you can use implements [TypeNum](../types/trait.TypeNum.html).
52+ ///
53+ /// Dimensions are represented by ndarray's
54+ /// [Dimension](https://docs.rs/ndarray/0.12/ndarray/trait.Dimension.html) trait.
5355///
5456/// Typically, you can use `Ix1, Ix2, ..` for fixed size arrays, and use `IxDyn` for dynamic
5557/// dimensioned arrays. They're re-exported from `ndarray` crate.
5658///
5759/// You can also use various type aliases we provide, like [`PyArray1`](./type.PyArray1.html)
5860/// or [`PyArrayDyn`](./type.PyArrayDyn.html).
5961///
60- /// Many constructor methods takes a type which implements
62+ /// To specify concrete dimension like `3×4×5`, you can use types which implements ndarray's
6163/// [`IntoDimension`](https://docs.rs/ndarray/0.12/ndarray/dimension/conversion/trait.IntoDimension.html)
6264/// trait. Typically, you can use array(e.g. `[3, 4, 5]`) or tuple(e.g. `(3, 4, 5)`) as a dimension.
65+ ///
6366/// # Example
6467/// ```
6568/// # #[macro_use] extern crate ndarray; extern crate pyo3; extern crate numpy; fn main() {
@@ -147,7 +150,7 @@ impl<T, D> IntoPyObject for PyArray<T, D> {
147150}
148151
149152impl < T , D > PyArray < T , D > {
150- /// Gets a raw `PyArrayObject` pointer.
153+ /// Gets a raw [ `PyArrayObject`](../npyffi/objects/struct.PyArrayObject.html) pointer.
151154 pub fn as_array_ptr ( & self ) -> * mut npyffi:: PyArrayObject {
152155 self . as_ptr ( ) as _
153156 }
@@ -416,9 +419,11 @@ impl<T: TypeNum, D: Dimension> PyArray<T, D> {
416419 ToPyArray :: to_pyarray ( arr, py)
417420 }
418421
419- /// Construct PyArray from `ndarray::Array`.
422+ /// Construct PyArray from
423+ /// [`ndarray::Array`](https://docs.rs/ndarray/0.12/ndarray/type.Array.html).
420424 ///
421- /// This method uses internal `Vec` of `ndarray::Array` as numpy array.
425+ /// This method uses internal [`Vec`](https://doc.rust-lang.org/std/vec/struct.Vec.html)
426+ /// of `ndarray::Array` as numpy array.
422427 ///
423428 /// # Example
424429 /// ```
@@ -433,7 +438,8 @@ impl<T: TypeNum, D: Dimension> PyArray<T, D> {
433438 IntoPyArray :: into_pyarray ( arr, py)
434439 }
435440
436- /// Get the immutable view of the internal data of `PyArray`, as `ndarray::ArrayView`.
441+ /// Get the immutable view of the internal data of `PyArray`, as
442+ /// [`ndarray::ArrayView`](https://docs.rs/ndarray/0.12/ndarray/type.ArrayView.html).
437443 ///
438444 /// # Example
439445 /// ```
@@ -579,7 +585,8 @@ impl<T: TypeNum> PyArray<T, Ix1> {
579585 array
580586 }
581587
582- /// Construct one-dimension PyArray from `Vec`.
588+ /// Construct one-dimension PyArray
589+ /// from [`Vec`](https://doc.rust-lang.org/std/vec/struct.Vec.html).
583590 ///
584591 /// # Example
585592 /// ```
@@ -595,7 +602,8 @@ impl<T: TypeNum> PyArray<T, Ix1> {
595602 IntoPyArray :: into_pyarray ( vec, py)
596603 }
597604
598- /// Construct one-dimension PyArray from `impl ExactSizeIterator`.
605+ /// Construct one-dimension PyArray from a type which implements
606+ /// [`ExactSizeIterator`](https://doc.rust-lang.org/std/iter/trait.ExactSizeIterator.html).
599607 ///
600608 /// # Example
601609 /// ```
@@ -618,10 +626,12 @@ impl<T: TypeNum> PyArray<T, Ix1> {
618626 array
619627 }
620628
621- /// Construct one-dimension PyArray from `impl IntoIterator`.
629+ /// Construct one-dimension PyArray from a type which implements
630+ /// [`IntoIterator`](https://doc.rust-lang.org/std/iter/trait.IntoIterator.html).
631+ ///
632+ /// This method can allocate memory multiple times and not fast.
633+ /// When you can use [from_exact_iter](method.from_exact_iter.html), we recommend to use it.
622634 ///
623- /// This method can allocate multiple times and not fast.
624- /// When you can use [from_exact_iter](method.from_exact_iter.html), please use it.
625635 /// # Example
626636 /// ```
627637 /// # extern crate pyo3; extern crate numpy; fn main() {
@@ -741,7 +751,7 @@ impl<T: TypeNum> PyArray<T, Ix3> {
741751 /// Construct a three-dimension PyArray from `Vec<Vec<Vec<T>>>`.
742752 ///
743753 /// This function checks all dimension of inner vec, and if there's any vec
744- /// where its dimension differs from others, it returns `ArrayCastError` .
754+ /// where its dimension differs from others, it returns error .
745755 ///
746756 /// # Example
747757 /// ```
0 commit comments