Skip to content

Commit

Permalink
Merge pull request #517 from jturner314/macro-use
Browse files Browse the repository at this point in the history
Bump to Rust 1.30, add macros to preludes, and switch macro_use to use
  • Loading branch information
bluss committed Nov 27, 2018
2 parents 22bc8ea + beec050 commit 1b1a503
Show file tree
Hide file tree
Showing 44 changed files with 66 additions and 110 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -4,7 +4,7 @@ sudo: required
dist: trusty
matrix:
include:
- rust: 1.27.0
- rust: 1.30.0
env:
- FEATURES='test docs'
- rust: stable
Expand Down
3 changes: 1 addition & 2 deletions benches/bench1.rs
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
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
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
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
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
5 changes: 3 additions & 2 deletions blas-tests/tests/oper.rs
@@ -1,5 +1,5 @@
#[macro_use] extern crate defmac;
#[macro_use(s)] extern crate ndarray;
extern crate defmac;
extern crate ndarray;
extern crate num_traits;

use ndarray::prelude::*;
Expand All @@ -9,6 +9,7 @@ use ndarray::linalg::general_mat_vec_mul;
use ndarray::{Ix, Ixs, SliceInfo, SliceOrIndex};

use std::fmt;
use defmac::defmac;
use num_traits::Float;

fn assert_approx_eq<F: fmt::Debug + Float>(f: F, g: F, tol: F) -> bool {
Expand Down
6 changes: 1 addition & 5 deletions examples/axis_ops.rs
@@ -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
@@ -1,5 +1,3 @@

#[macro_use]
extern crate ndarray;

use ndarray::prelude::*;
Expand Down
1 change: 0 additions & 1 deletion examples/convo.rs
@@ -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
@@ -1,4 +1,3 @@
#[macro_use]
extern crate ndarray;

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

#[macro_use]
extern crate ndarray;

use ndarray::prelude::*;
Expand Down
2 changes: 0 additions & 2 deletions examples/zip_many.rs
@@ -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
@@ -1,5 +1,3 @@

#[macro_use(s)]
extern crate ndarray;
extern crate ndarray_rand;
extern crate rand;
Expand Down
4 changes: 2 additions & 2 deletions parallel/benches/rayon.rs
Expand Up @@ -6,8 +6,8 @@ extern crate test;
use test::Bencher;

extern crate rayon;
#[macro_use] extern crate ndarray;
#[macro_use] extern crate ndarray_parallel;
extern crate ndarray;
extern crate ndarray_parallel;
use ndarray::prelude::*;
use ndarray_parallel::prelude::*;

Expand Down
4 changes: 3 additions & 1 deletion parallel/src/lib.rs
Expand Up @@ -98,8 +98,10 @@
pub extern crate ndarray;
pub extern crate rayon;

/// Into- traits for creating parallelized iterators.
/// Into- traits for creating parallelized iterators and `par_azip` macro.
pub mod prelude {
pub use par_azip;

// happy and insane; ignorance is bluss
pub use NdarrayIntoParallelIterator;
pub use NdarrayIntoParallelRefIterator;
Expand Down
2 changes: 1 addition & 1 deletion parallel/src/zipmacro.rs
Expand Up @@ -31,10 +31,10 @@
///
/// ```rust
/// extern crate ndarray;
/// #[macro_use(par_azip)]
/// extern crate ndarray_parallel;
///
/// use ndarray::Array2;
/// use ndarray_parallel::par_azip;
///
/// type M = Array2<f32>;
///
Expand Down
2 changes: 1 addition & 1 deletion parallel/tests/azip.rs
@@ -1,10 +1,10 @@

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

use ndarray::prelude::*;
use ndarray_parallel::par_azip;
use itertools::{enumerate};
use std::sync::atomic::{AtomicUsize, Ordering};

Expand Down
2 changes: 1 addition & 1 deletion parallel/tests/rayon.rs
@@ -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
@@ -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: 1 addition & 1 deletion src/dimension/dimension_trait.rs
Expand Up @@ -11,7 +11,7 @@ use std::fmt::Debug;
use std::ops::{Index, IndexMut};
use std::ops::{Add, Sub, Mul, AddAssign, SubAssign, MulAssign};

use itertools::{enumerate, zip};
use itertools::{enumerate, izip, zip};

use {Ix, Ixs, Ix0, Ix1, Ix2, Ix3, Ix4, Ix5, Ix6, IxDyn, Dim, SliceOrIndex, IxDynImpl};
use IntoDimension;
Expand Down
2 changes: 2 additions & 0 deletions src/dimension/mod.rs
Expand Up @@ -8,6 +8,7 @@

use {Ix, Ixs};
use error::{from_kind, ErrorKind, ShapeError};
use itertools::izip;

pub use self::dim::*;
pub use self::axis::Axis;
Expand Down Expand Up @@ -428,6 +429,7 @@ mod test {
can_index_slice, can_index_slice_not_custom, max_abs_offset_check_overflow, IntoDimension
};
use error::{from_kind, ErrorKind};
use quickcheck::quickcheck;
use {Dimension, Ix0, Ix1, Ix2, Ix3, IxDyn};

#[test]
Expand Down
2 changes: 0 additions & 2 deletions src/doc/ndarray_for_numpy_users/coord_transform.rs
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
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
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
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
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
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
2 changes: 1 addition & 1 deletion src/impl_methods.rs
Expand Up @@ -10,7 +10,7 @@ use std::cmp;
use std::ptr as std_ptr;
use std::slice;

use itertools::zip;
use itertools::{izip, zip};

use imp_prelude::*;

Expand Down
13 changes: 5 additions & 8 deletions src/lib.rs
Expand Up @@ -56,7 +56,7 @@
//! + Efficient floating point matrix multiplication even for very large
//! matrices; can optionally use BLAS to improve it further.
//! + See also the [`ndarray-parallel`] crate for integration with rayon.
//! - **Requires Rust 1.27**
//! - **Requires Rust 1.30**
//!
//! [`ndarray-parallel`]: https://docs.rs/ndarray-parallel
//!
Expand Down Expand Up @@ -99,12 +99,11 @@ extern crate blas_src;

extern crate matrixmultiply;

#[macro_use(izip)] extern crate itertools;
extern crate itertools;
extern crate num_traits as libnum;
extern crate num_complex;

#[cfg(test)]
#[macro_use(quickcheck)]
extern crate quickcheck;

#[cfg(feature = "docs")]
Expand Down Expand Up @@ -470,11 +469,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 +551,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
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

0 comments on commit 1b1a503

Please sign in to comment.