From ca102008dee19efd9b1c63788ebf8f3088ad0525 Mon Sep 17 00:00:00 2001 From: bluss Date: Sun, 19 Apr 2020 08:46:19 +0200 Subject: [PATCH 1/4] DOC: Add to 0.13.1 changelog --- RELEASES.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index 071d12464..56741a7e0 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -14,7 +14,10 @@ New features https://github.com/rust-ndarray/ndarray/pull/728 - `Dimension::Larger` now requires `RemoveAxis` by [@TheLortex] https://github.com/rust-ndarray/ndarray/pull/792 - +- New methods for collecting Zip into an array by [@bluss] + https://github.com/rust-ndarray/ndarray/pull/797 +- New `Array::maybe_uninit` and `.assume_init()` by [@bluss] + https://github.com/rust-ndarray/ndarray/pull/803 Enhancements ------------ @@ -25,6 +28,8 @@ Enhancements https://github.com/rust-ndarray/ndarray/pull/754 - Implement `fold` for `IndicesIter` by [@jturner314] https://github.com/rust-ndarray/ndarray/pull/733 +- New Quick Start readme by [@lifuyang] + https://github.com/rust-ndarray/ndarray/pull/785 API changes ----------- @@ -39,6 +44,9 @@ Other changes - Improve blas version documentation by [@jturner314] - Doc improvements by [@mockersf] https://github.com/rust-ndarray/ndarray/pull/751 - Doc and lint related improvements by [@viniciusd] https://github.com/rust-ndarray/ndarray/pull/750 +- Minor fixes related to best practices for unsafe code by [@bluss] + https://github.com/rust-ndarray/ndarray/pull/799 + https://github.com/rust-ndarray/ndarray/pull/802 - Release management by [@bluss] @@ -944,3 +952,4 @@ Earlier releases [@TheLortex]: https://github.com/TheLortex [@mockersf]: https://github.com/mockersf [@viniciusd]: https://github.com/viniciusd +[@lifuyang]: https://github.com/liufuyang From 3ddfbeeb672b3e6380c97b7dc9837ef93af0fbcb Mon Sep 17 00:00:00 2001 From: bluss Date: Mon, 20 Apr 2020 21:08:13 +0200 Subject: [PATCH 2/4] DOC: Update Array::uninitialized's example and doc See the bug reports; these examples can not really be recommended; instead we recommend using Array::maybe_uninit. --- src/impl_constructors.rs | 37 ++++++++----------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/src/impl_constructors.rs b/src/impl_constructors.rs index 964003dd8..62c1f2aa2 100644 --- a/src/impl_constructors.rs +++ b/src/impl_constructors.rs @@ -474,41 +474,20 @@ where /// /// ### Safety /// - /// Accessing uninitalized values is undefined behaviour. You must - /// overwrite *all* the elements in the array after it is created; for - /// example using the methods `.fill()` or `.assign()`. + /// Accessing uninitalized values is undefined behaviour. You must overwrite *all* the elements + /// in the array after it is created; for example using + /// [`raw_view_mut`](ArrayBase::raw_view_mut) or other low-level element access. /// /// The contents of the array is indeterminate before initialization and it /// is an error to perform operations that use the previous values. For /// example it would not be legal to use `a += 1.;` on such an array. /// /// This constructor is limited to elements where `A: Copy` (no destructors) - /// to avoid users shooting themselves too hard in the foot; it is not - /// a problem to drop an array created with this method even before elements - /// are initialized. (Note that constructors `from_shape_vec` and - /// `from_shape_vec_unchecked` allow the user yet more control). - /// - /// ### Examples - /// - /// ``` - /// use ndarray::{s, Array2}; - /// - /// // Example Task: Let's create a column shifted copy of a in b - /// - /// fn shift_by_two(a: &Array2) -> Array2 { - /// let mut b = unsafe { Array2::uninitialized(a.dim()) }; - /// - /// // two first columns in b are two last in a - /// // rest of columns in b are the initial columns in a - /// b.slice_mut(s![.., ..2]).assign(&a.slice(s![.., -2..])); - /// b.slice_mut(s![.., 2..]).assign(&a.slice(s![.., ..-2])); - /// - /// // `b` is safe to use with all operations at this point - /// b - /// } - /// - /// # shift_by_two(&Array2::zeros((8, 8))); - /// ``` + /// to avoid users shooting themselves too hard in the foot. + /// + /// (Also note that the constructors `from_shape_vec` and + /// `from_shape_vec_unchecked` allow the user yet more control, in the sense + /// that Arrays can be created from arbitrary vectors.) pub unsafe fn uninitialized(shape: Sh) -> Self where A: Copy, From 80dd490ec7b382d8910f6aaf380360bf82e8e1a6 Mon Sep 17 00:00:00 2001 From: bluss Date: Mon, 20 Apr 2020 21:09:52 +0200 Subject: [PATCH 3/4] DOC: Correct typo and improve maybe_uninit's example The example is very far from perfect, but it works ;) In the long run maybe the example's assign_to function can have a place in ndarray --- src/impl_constructors.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/impl_constructors.rs b/src/impl_constructors.rs index 62c1f2aa2..8d1471e78 100644 --- a/src/impl_constructors.rs +++ b/src/impl_constructors.rs @@ -533,7 +533,7 @@ where /// use ndarray::Zip; /// use ndarray::Axis; /// - /// // Example Task: Let's create a transposed copy of the input + /// // Example Task: Let's create a column shifted copy of the input /// /// fn shift_by_two(a: &Array2) -> Array2 { /// // create an uninitialized array @@ -553,6 +553,8 @@ where /// /// use ndarray::{IntoNdProducer, AssignElem}; /// + /// // This function clones elements from the first input to the second; + /// // the two producers must have the same shape /// fn assign_to<'a, P1, P2, A>(from: P1, to: P2) /// where P1: IntoNdProducer, /// P2: IntoNdProducer, From 1f6d249cca221ded3bb8d7498aa61f34e6dc0c33 Mon Sep 17 00:00:00 2001 From: bluss Date: Mon, 20 Apr 2020 21:24:38 +0200 Subject: [PATCH 4/4] DOC: Put release date on 0.13.1 --- RELEASES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index 56741a7e0..b5e351e92 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,4 +1,4 @@ -Version 0.13.1 (2020-04) +Version 0.13.1 (2020-04-21) =========================== New features