Skip to content

Commit

Permalink
Add array, azip, and s macros to prelude
Browse files Browse the repository at this point in the history
Also remove `macro_use` of `array`, `azip`, `s`, and `stack`, and
replace with normal `use` statements.
  • Loading branch information
jturner314 committed Nov 21, 2018
1 parent 906ca86 commit 644c3bd
Show file tree
Hide file tree
Showing 35 changed files with 25 additions and 75 deletions.
3 changes: 1 addition & 2 deletions benches/bench1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#![allow(unused_imports)]

extern crate test;
#[macro_use(s, azip)]
extern crate ndarray;

use ndarray::{
Expand All @@ -13,7 +12,7 @@ use ndarray::{
Array2,
Zip,
};
use ndarray::{arr0, arr1, arr2};
use ndarray::{arr0, arr1, arr2, azip, s};
use ndarray::ShapeBuilder;

use test::black_box;
Expand Down
1 change: 0 additions & 1 deletion benches/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
extern crate test;
use test::Bencher;

#[macro_use(azip)]
extern crate ndarray;
use ndarray::prelude::*;
use ndarray::NdProducer;
Expand Down
1 change: 0 additions & 1 deletion benches/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
extern crate test;
use test::Bencher;

#[macro_use(s)]
extern crate ndarray;
use ndarray::prelude::*;

Expand Down
1 change: 0 additions & 1 deletion benches/higher-order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ extern crate test;
use test::Bencher;
use test::black_box;

#[macro_use(s)]
extern crate ndarray;
use ndarray::prelude::*;

Expand Down
1 change: 0 additions & 1 deletion benches/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use test::Bencher;
use test::black_box;
use rawpointer::PointerExt;

#[macro_use(s, azip)]
extern crate ndarray;
use ndarray::prelude::*;
use ndarray::{Zip, FoldWhile};
Expand Down
2 changes: 1 addition & 1 deletion blas-tests/tests/oper.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[macro_use] extern crate defmac;
#[macro_use(s)] extern crate ndarray;
extern crate ndarray;
extern crate num_traits;

use ndarray::prelude::*;
Expand Down
6 changes: 1 addition & 5 deletions examples/axis_ops.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@

#[macro_use(s)]
extern crate ndarray;

use ndarray::Array;
use ndarray::Dimension;
use ndarray::Axis;
use ndarray::prelude::*;

fn regularize<A, D>(a: &mut Array<A, D>) -> Result<(), ()>
where D: Dimension,
Expand Down
2 changes: 0 additions & 2 deletions examples/column_standardize.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

#[macro_use]
extern crate ndarray;

use ndarray::prelude::*;
Expand Down
1 change: 0 additions & 1 deletion examples/convo.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![allow(unused)]
#[macro_use(s)]
extern crate ndarray;
extern crate num_traits;

Expand Down
1 change: 0 additions & 1 deletion examples/life.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[macro_use]
extern crate ndarray;

use ndarray::prelude::*;
Expand Down
2 changes: 0 additions & 2 deletions examples/rollaxis.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

#[macro_use]
extern crate ndarray;

use ndarray::prelude::*;
Expand Down
2 changes: 0 additions & 2 deletions examples/zip_many.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

#[macro_use]
extern crate ndarray;

use ndarray::prelude::*;
Expand Down
2 changes: 0 additions & 2 deletions numeric-tests/tests/accuracy.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

#[macro_use(s)]
extern crate ndarray;
extern crate ndarray_rand;
extern crate rand;
Expand Down
2 changes: 1 addition & 1 deletion parallel/benches/rayon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ extern crate test;
use test::Bencher;

extern crate rayon;
#[macro_use] extern crate ndarray;
extern crate ndarray;
#[macro_use] extern crate ndarray_parallel;
use ndarray::prelude::*;
use ndarray_parallel::prelude::*;
Expand Down
2 changes: 1 addition & 1 deletion parallel/tests/rayon.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

extern crate rayon;
#[macro_use(s)] extern crate ndarray;
extern crate ndarray;
extern crate ndarray_parallel;

use ndarray::prelude::*;
Expand Down
4 changes: 2 additions & 2 deletions serialization-tests/tests/serialize.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extern crate rustc_serialize as serialize;

#[macro_use] extern crate ndarray;
extern crate ndarray;

extern crate serde;

Expand All @@ -14,7 +14,7 @@ extern crate ron;
use serialize::json;


use ndarray::{arr0, arr1, arr2, RcArray, RcArray1, RcArray2, ArrayD, IxDyn};
use ndarray::{arr0, arr1, arr2, s, RcArray, RcArray1, RcArray2, ArrayD, IxDyn};

#[test]
fn serial_many_dim()
Expand Down
2 changes: 0 additions & 2 deletions src/doc/ndarray_for_numpy_users/coord_transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
//! This is a direct translation to `ndarray`:
//!
//! ```
//! #[macro_use]
//! extern crate ndarray;
//!
//! use ndarray::prelude::*;
Expand Down Expand Up @@ -97,7 +96,6 @@
//! this:
//!
//! ```
//! #[macro_use]
//! extern crate ndarray;
//!
//! use ndarray::prelude::*;
Expand Down
1 change: 0 additions & 1 deletion src/doc/ndarray_for_numpy_users/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@
//! and `ndarray` like this:
//!
//! ```
//! #[macro_use]
//! extern crate ndarray;
//!
//! use ndarray::prelude::*;
Expand Down
2 changes: 0 additions & 2 deletions src/doc/ndarray_for_numpy_users/rk_step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
//! A direct translation to `ndarray` looks like this:
//!
//! ```
//! #[macro_use]
//! extern crate ndarray;
//!
//! use ndarray::prelude::*;
Expand Down Expand Up @@ -130,7 +129,6 @@
//! some places, but that's not demonstrated in the example below.
//!
//! ```
//! #[macro_use]
//! extern crate ndarray;
//!
//! use ndarray::prelude::*;
Expand Down
2 changes: 0 additions & 2 deletions src/doc/ndarray_for_numpy_users/simple_math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
//!
//!
//!
//!
//! a = np.full((5, 4), 3.)
//!
//!
Expand Down Expand Up @@ -52,7 +51,6 @@
//! <td>
//!
//! ```
//! #[macro_use]
//! extern crate ndarray;
//!
//! use ndarray::prelude::*;
Expand Down
6 changes: 3 additions & 3 deletions src/free_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ use imp_prelude::*;
/// three dimensions.
///
/// ```
/// #[macro_use(array)]
/// extern crate ndarray;
///
/// use ndarray::array;
///
/// fn main() {
/// let a1 = array![1, 2, 3, 4];
///
Expand Down Expand Up @@ -115,10 +116,9 @@ pub fn aview2<A, V: FixedInitializer<Elem=A>>(xs: &[V]) -> ArrayView2<A> {
/// Create a one-dimensional read-write array view with elements borrowing `xs`.
///
/// ```
/// #[macro_use(s)]
/// extern crate ndarray;
///
/// use ndarray::aview_mut1;
/// use ndarray::{aview_mut1, s};
///
/// // Create an array view over some data, then slice it and modify it.
/// fn main() {
Expand Down
3 changes: 1 addition & 2 deletions src/impl_constructors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,9 @@ impl<S, A, D> ArrayBase<S, D>
/// ### Examples
///
/// ```
/// #[macro_use(s)]
/// extern crate ndarray;
///
/// use ndarray::Array2;
/// use ndarray::{s, Array2};
///
/// // Example Task: Let's create a column shifted copy of a in b
///
Expand Down
8 changes: 3 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,11 +470,9 @@ pub type Ixs = isize;
/// [`.slice_collapse()`]: #method.slice_collapse
///
/// ```
/// // import the s![] macro
/// #[macro_use(s)]
/// extern crate ndarray;
///
/// use ndarray::{arr2, arr3};
/// use ndarray::{arr2, arr3, s};
///
/// fn main() {
///
Expand Down Expand Up @@ -554,9 +552,9 @@ pub type Ixs = isize;
/// [`.outer_iter_mut()`]: #method.outer_iter_mut
///
/// ```
/// #[macro_use(s)] extern crate ndarray;
/// extern crate ndarray;
///
/// use ndarray::{arr3, aview1, aview2, Axis};
/// use ndarray::{arr3, aview1, aview2, s, Axis};
///
/// # fn main() {
///
Expand Down
6 changes: 4 additions & 2 deletions src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

//! ndarray prelude.
//!
//! This module contains the most used types, type aliases, traits and
//! functions that you can import easily as a group.
//! This module contains the most used types, type aliases, traits, functions,
//! and macros that you can import easily as a group.
//!
//! ```
//! extern crate ndarray;
Expand Down Expand Up @@ -55,6 +55,8 @@ pub use {
aview_mut1,
};

pub use {array, azip, s};

#[doc(no_inline)]
pub use {
ShapeBuilder,
Expand Down
4 changes: 1 addition & 3 deletions src/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,9 @@ impl_slicenextdim_larger!((), Slice);
/// # Example
///
/// ```
/// #[macro_use]
/// extern crate ndarray;
///
/// use ndarray::{Array2, ArrayView2};
/// use ndarray::{s, Array2, ArrayView2};
///
/// fn laplacian(v: &ArrayView2<f32>) -> Array2<f32> {
/// -4. * &v.slice(s![1..-1, 1..-1])
Expand Down Expand Up @@ -533,7 +532,6 @@ impl_slicenextdim_larger!((), Slice);
/// For example,
///
/// ```
/// # #[macro_use]
/// # extern crate ndarray;
/// #
/// # use ndarray::prelude::*;
Expand Down
3 changes: 1 addition & 2 deletions src/stacking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,9 @@ pub fn stack<'a, A, D>(axis: Axis, arrays: &[ArrayView<'a, A, D>])
/// ***Panics*** if the `stack` function would return an error.
///
/// ```
/// #[macro_use(stack)]
/// extern crate ndarray;
///
/// use ndarray::{arr2, Axis};
/// use ndarray::{arr2, stack, Axis};
///
/// # fn main() {
///
Expand Down
3 changes: 1 addition & 2 deletions src/zip/zipmacro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@
/// ## Examples
///
/// ```rust
/// #[macro_use(azip)]
/// extern crate ndarray;
///
/// use ndarray::{Array1, Array2, Axis};
/// use ndarray::{azip, Array1, Array2, Axis};
///
/// type M = Array2<f32>;
///
Expand Down
1 change: 0 additions & 1 deletion tests/array.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![allow(non_snake_case)]

#[macro_use]
extern crate ndarray;
#[macro_use]
extern crate defmac;
Expand Down
1 change: 0 additions & 1 deletion tests/azip.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[macro_use]
extern crate ndarray;
extern crate itertools;

Expand Down
2 changes: 0 additions & 2 deletions tests/iterator_chunks.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

#[macro_use(array, s)]
extern crate ndarray;

use ndarray::prelude::*;
Expand Down
12 changes: 1 addition & 11 deletions tests/iterators.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
#[macro_use(s)]
extern crate ndarray;
extern crate itertools;

use ndarray::prelude::*;
use ndarray::Ix;
use ndarray::{
Data,
Dimension,
aview1,
arr2,
arr3,
Axis,
indices,
Slice,
};
use ndarray::{arr2, arr3, aview1, indices, s, Axis, Data, Dimension, Slice};

use itertools::assert_equal;
use itertools::{rev, enumerate};
Expand Down
2 changes: 1 addition & 1 deletion tests/oper.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[macro_use] extern crate defmac;
#[macro_use(s)] extern crate ndarray;
extern crate ndarray;
extern crate num_traits;

use ndarray::prelude::*;
Expand Down
4 changes: 1 addition & 3 deletions tests/s.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

#[macro_use(s)]
extern crate ndarray;

use ndarray::Array;
use ndarray::{s, Array};

#[test]
fn test_s()
Expand Down
3 changes: 1 addition & 2 deletions tests/stacking.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

#[macro_use(stack)]
extern crate ndarray;


use ndarray::{
aview1,
arr2,
stack,
Axis,
Array2,
ErrorKind,
Expand Down
2 changes: 0 additions & 2 deletions tests/windows.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

#[macro_use(s)]
extern crate ndarray;
extern crate itertools;

Expand Down

0 comments on commit 644c3bd

Please sign in to comment.