Skip to content

Commit 3ea6861

Browse files
authored
Merge pull request #812 from rust-ndarray/examples-extern-crate
Small fixes in examples and docs
2 parents 3450d09 + 778575f commit 3ea6861

File tree

10 files changed

+29
-40
lines changed

10 files changed

+29
-40
lines changed

src/doc/ndarray_for_numpy_users/coord_transform.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@
4949
//! This is a direct translation to `ndarray`:
5050
//!
5151
//! ```
52-
//! extern crate ndarray;
53-
//!
5452
//! use ndarray::prelude::*;
5553
//!
5654
//! fn main() {
@@ -96,8 +94,6 @@
9694
//! this:
9795
//!
9896
//! ```
99-
//! extern crate ndarray;
100-
//!
10197
//! use ndarray::prelude::*;
10298
//!
10399
//! fn main() {

src/doc/ndarray_for_numpy_users/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,6 @@
177177
//! and `ndarray` like this:
178178
//!
179179
//! ```
180-
//! extern crate ndarray;
181-
//!
182180
//! use ndarray::prelude::*;
183181
//! #
184182
//! # fn main() {}

src/doc/ndarray_for_numpy_users/rk_step.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@
7171
//! A direct translation to `ndarray` looks like this:
7272
//!
7373
//! ```
74-
//! extern crate ndarray;
75-
//!
7674
//! use ndarray::prelude::*;
7775
//!
7876
//! fn rk_step<F>(
@@ -129,8 +127,6 @@
129127
//! some places, but that's not demonstrated in the example below.
130128
//!
131129
//! ```
132-
//! extern crate ndarray;
133-
//!
134130
//! use ndarray::prelude::*;
135131
//!
136132
//! fn rk_step<F>(

src/doc/ndarray_for_numpy_users/simple_math.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@
5151
//! <td>
5252
//!
5353
//! ```
54-
//! extern crate ndarray;
55-
//!
5654
//! use ndarray::prelude::*;
5755
//!
5856
//! # fn main() {

src/lib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@
5252
//! - Performance:
5353
//! + Prefer higher order methods and arithmetic operations on arrays first,
5454
//! then iteration, and as a last priority using indexed algorithms.
55-
//! + The higher order functions like ``.map()``, ``.map_inplace()``,
56-
//! ``.zip_mut_with()``, ``Zip`` and ``azip!()`` are the most efficient ways
55+
//! + The higher order functions like [`.map()`](ArrayBase::map),
56+
//! [`.map_inplace()`](ArrayBase::map_inplace), [`.zip_mut_with()`](ArrayBase::zip_mut_with),
57+
//! [`Zip`] and [`azip!()`](azip) are the most efficient ways
5758
//! to perform single traversal and lock step traversal respectively.
5859
//! + Performance of an operation depends on the memory layout of the array
5960
//! or array view. Especially if it's a binary operation, which
@@ -299,9 +300,10 @@ pub type Ixs = isize;
299300
/// Please see the documentation for the respective array view for an overview
300301
/// of methods specific to array views: [`ArrayView`], [`ArrayViewMut`].
301302
///
302-
/// A view is created from an array using `.view()`, `.view_mut()`, using
303-
/// slicing (`.slice()`, `.slice_mut()`) or from one of the many iterators
304-
/// that yield array views.
303+
/// A view is created from an array using [`.view()`](ArrayBase::view),
304+
/// [`.view_mut()`](ArrayBase::view_mut), using
305+
/// slicing ([`.slice()`](ArrayBase::slice), [`.slice_mut()`](ArrayBase::slice_mut)) or from one of
306+
/// the many iterators that yield array views.
305307
///
306308
/// You can also create an array view from a regular slice of data not
307309
/// allocated with `Array` — see array view methods or their `From` impls.

src/parallel/mod.rs

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
//! The following types implement parallel iterators, accessed using these
1111
//! methods:
1212
//!
13-
//! - [`Array`], [`ArcArray`]: `.par_iter()` and `.par_iter_mut()`
14-
//! - [`ArrayView`](ArrayView): `.into_par_iter()`
15-
//! - [`ArrayViewMut`](ArrayViewMut): `.into_par_iter()`
16-
//! - [`AxisIter`](iter::AxisIter), [`AxisIterMut`](iter::AxisIterMut): `.into_par_iter()`
17-
//! - [`AxisChunksIter`](iter::AxisChunksIter), [`AxisChunksIterMut`](iter::AxisChunksIterMut): `.into_par_iter()`
13+
//! - [`Array`], [`ArcArray`] `.par_iter()` and `.par_iter_mut()`
14+
//! - [`ArrayView`] `.into_par_iter()`
15+
//! - [`ArrayViewMut`] `.into_par_iter()`
16+
//! - [`AxisIter`], [`AxisIterMut`] `.into_par_iter()`
17+
//! - [`AxisChunksIter`], [`AxisChunksIterMut`] `.into_par_iter()`
1818
//! - [`Zip`] `.into_par_iter()`
1919
//!
2020
//! The following other parallelized methods exist:
@@ -39,8 +39,6 @@
3939
//! Compute the exponential of each element in an array, parallelized.
4040
//!
4141
//! ```
42-
//! extern crate ndarray;
43-
//!
4442
//! use ndarray::Array2;
4543
//! use ndarray::parallel::prelude::*;
4644
//!
@@ -61,8 +59,6 @@
6159
//! Use the parallel `.axis_iter()` to compute the sum of each row.
6260
//!
6361
//! ```
64-
//! extern crate ndarray;
65-
//!
6662
//! use ndarray::Array;
6763
//! use ndarray::Axis;
6864
//! use ndarray::parallel::prelude::*;
@@ -84,8 +80,6 @@
8480
//! Use the parallel `.axis_chunks_iter()` to process your data in chunks.
8581
//!
8682
//! ```
87-
//! extern crate ndarray;
88-
//!
8983
//! use ndarray::Array;
9084
//! use ndarray::Axis;
9185
//! use ndarray::parallel::prelude::*;
@@ -107,8 +101,6 @@
107101
//! Use zip for lock step function application across several arrays
108102
//!
109103
//! ```
110-
//! extern crate ndarray;
111-
//!
112104
//! use ndarray::Array3;
113105
//! use ndarray::Zip;
114106
//!
@@ -129,6 +121,23 @@
129121
//! }
130122
//! ```
131123
124+
#[allow(unused_imports)] // used by rustdoc links
125+
use crate::{
126+
ArrayBase,
127+
Array,
128+
ArcArray,
129+
ArrayView,
130+
ArrayViewMut,
131+
Zip,
132+
};
133+
#[allow(unused_imports)] // used by rustdoc links
134+
use crate::iter::{
135+
AxisIter,
136+
AxisIterMut,
137+
AxisChunksIter,
138+
AxisChunksIterMut,
139+
};
140+
132141
/// Into- traits for creating parallelized iterators and/or using [`par_azip!`]
133142
pub mod prelude {
134143
#[doc(no_inline)]

src/parallel/zipmacro.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
/// ## Examples
3535
///
3636
/// ```rust
37-
/// extern crate ndarray;
38-
///
3937
/// use ndarray::Array2;
4038
/// use ndarray::parallel::par_azip;
4139
///

src/slice.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,6 @@ impl_slicenextdim_larger!((), Slice);
496496
/// # Example
497497
///
498498
/// ```
499-
/// extern crate ndarray;
500-
///
501499
/// use ndarray::{s, Array2, ArrayView2};
502500
///
503501
/// fn laplacian(v: &ArrayView2<f32>) -> Array2<f32> {
@@ -528,8 +526,6 @@ impl_slicenextdim_larger!((), Slice);
528526
/// For example,
529527
///
530528
/// ```
531-
/// # extern crate ndarray;
532-
/// #
533529
/// # use ndarray::prelude::*;
534530
/// #
535531
/// # fn main() {

src/stacking.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ where
8686
/// ***Panics*** if the `stack` function would return an error.
8787
///
8888
/// ```
89-
/// extern crate ndarray;
90-
///
9189
/// use ndarray::{arr2, stack, Axis};
9290
///
9391
/// # fn main() {

src/zip/zipmacro.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
/// ## Examples
3939
///
4040
/// ```rust
41-
/// extern crate ndarray;
42-
///
4341
/// use ndarray::{azip, Array1, Array2, Axis};
4442
///
4543
/// type M = Array2<f32>;

0 commit comments

Comments
 (0)