@@ -23,43 +23,46 @@ use types::{NpyDataType, TypeNum};
23
23
/// - Case1: Constructed via [`IntoPyArray`](../convert/trait.IntoPyArray.html) or
24
24
/// [`from_vec`](#method.from_vec) or [`from_owned_array`](#method.from_owned_vec).
25
25
///
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.
27
27
///
28
28
/// Please take care that **you cannot use some destructive methods like `resize`,
29
29
/// for this kind of array**.
30
30
///
31
31
/// - Case2: Constructed via other methods, like [`ToPyArray`](../convert/trait.ToPyArray.html) or
32
32
/// [`from_slice`](#method.from_slice) or [`from_array`](#from_array).
33
33
///
34
- /// These methods allocate a memory area in Python's private heap.
34
+ /// These methods allocate memory in Python's private heap.
35
35
///
36
- /// In both cases, **an internal buffer of ` PyArray` is managed by Python GC.**
36
+ /// In both cases, **PyArray is managed by Python GC.**
37
37
/// So you can neither retrieve it nor deallocate it manually.
38
38
///
39
39
/// # Reference
40
40
///
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`.
42
42
///
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) .
45
45
///
46
46
///
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.
50
50
///
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.
53
55
///
54
56
/// Typically, you can use `Ix1, Ix2, ..` for fixed size arrays, and use `IxDyn` for dynamic
55
57
/// dimensioned arrays. They're re-exported from `ndarray` crate.
56
58
///
57
59
/// You can also use various type aliases we provide, like [`PyArray1`](./type.PyArray1.html)
58
60
/// or [`PyArrayDyn`](./type.PyArrayDyn.html).
59
61
///
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
61
63
/// [`IntoDimension`](https://docs.rs/ndarray/0.12/ndarray/dimension/conversion/trait.IntoDimension.html)
62
64
/// trait. Typically, you can use array(e.g. `[3, 4, 5]`) or tuple(e.g. `(3, 4, 5)`) as a dimension.
65
+ ///
63
66
/// # Example
64
67
/// ```
65
68
/// # #[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> {
147
150
}
148
151
149
152
impl < T , D > PyArray < T , D > {
150
- /// Gets a raw `PyArrayObject` pointer.
153
+ /// Gets a raw [ `PyArrayObject`](../npyffi/objects/struct.PyArrayObject.html) pointer.
151
154
pub fn as_array_ptr ( & self ) -> * mut npyffi:: PyArrayObject {
152
155
self . as_ptr ( ) as _
153
156
}
@@ -416,9 +419,11 @@ impl<T: TypeNum, D: Dimension> PyArray<T, D> {
416
419
ToPyArray :: to_pyarray ( arr, py)
417
420
}
418
421
419
- /// Construct PyArray from `ndarray::Array`.
422
+ /// Construct PyArray from
423
+ /// [`ndarray::Array`](https://docs.rs/ndarray/0.12/ndarray/type.Array.html).
420
424
///
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.
422
427
///
423
428
/// # Example
424
429
/// ```
@@ -433,7 +438,8 @@ impl<T: TypeNum, D: Dimension> PyArray<T, D> {
433
438
IntoPyArray :: into_pyarray ( arr, py)
434
439
}
435
440
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).
437
443
///
438
444
/// # Example
439
445
/// ```
@@ -579,7 +585,8 @@ impl<T: TypeNum> PyArray<T, Ix1> {
579
585
array
580
586
}
581
587
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).
583
590
///
584
591
/// # Example
585
592
/// ```
@@ -595,7 +602,8 @@ impl<T: TypeNum> PyArray<T, Ix1> {
595
602
IntoPyArray :: into_pyarray ( vec, py)
596
603
}
597
604
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).
599
607
///
600
608
/// # Example
601
609
/// ```
@@ -618,10 +626,12 @@ impl<T: TypeNum> PyArray<T, Ix1> {
618
626
array
619
627
}
620
628
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.
622
634
///
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.
625
635
/// # Example
626
636
/// ```
627
637
/// # extern crate pyo3; extern crate numpy; fn main() {
@@ -741,7 +751,7 @@ impl<T: TypeNum> PyArray<T, Ix3> {
741
751
/// Construct a three-dimension PyArray from `Vec<Vec<Vec<T>>>`.
742
752
///
743
753
/// 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 .
745
755
///
746
756
/// # Example
747
757
/// ```
0 commit comments