Skip to content

Commit 935463e

Browse files
authored
Merge pull request #103 from kngwyu/get-docfix
FIx the documents of PyArray::get/get_mut
2 parents b54bb16 + e86db83 commit 935463e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/array.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -481,12 +481,11 @@ impl<T: TypeNum, D: Dimension> PyArray<T, D> {
481481
unsafe { ArrayViewMut::from_shape_ptr(self.ndarray_shape(), self.data()) }
482482
}
483483

484-
/// Get an immutable reference of a specified element, without checking the
485-
/// passed index is valid.
484+
/// Get an immutable reference of a specified element, with checking the passed index is valid.
486485
///
487486
/// See [NpyIndex](../convert/trait.NpyIndex.html) for what types you can use as index.
488487
///
489-
/// Passing an invalid index can cause undefined behavior(mostly SIGSEGV).
488+
/// If you pass an invalid index to this function, it returns `None`.
490489
///
491490
/// # Example
492491
/// ```
@@ -499,7 +498,7 @@ impl<T: TypeNum, D: Dimension> PyArray<T, D> {
499498
/// # }
500499
/// ```
501500
///
502-
/// For fixed dimension arrays, too long/short index causes compile error.
501+
/// For fixed dimension arrays, passing an index with invalid dimension causes compile error.
503502
/// ```compile_fail
504503
/// # extern crate pyo3; extern crate numpy; fn main() {
505504
/// use numpy::PyArray;
@@ -508,7 +507,8 @@ impl<T: TypeNum, D: Dimension> PyArray<T, D> {
508507
/// let a = arr.get([1, 2]); // Compile Error!
509508
/// # }
510509
/// ```
511-
/// But, for dinamic errors too long/short index returns `None`.
510+
///
511+
/// However, for dinamic arrays, we cannot raise a compile error and just returns `None`.
512512
/// ```
513513
/// # extern crate pyo3; extern crate numpy; fn main() {
514514
/// use numpy::PyArray;
@@ -527,7 +527,7 @@ impl<T: TypeNum, D: Dimension> PyArray<T, D> {
527527
unsafe { Some(&*self.data().offset(offset)) }
528528
}
529529

530-
/// Same as [get](#method.get), but returns `&mut T`.
530+
/// Same as [get](#method.get), but returns `Option<&mut T>`.
531531
#[inline(always)]
532532
pub fn get_mut<Idx>(&self, index: Idx) -> Option<&mut T>
533533
where

0 commit comments

Comments
 (0)