Skip to content

Commit

Permalink
FIX: Use $crate in par_azip and add to the ndarray::parallel prelude
Browse files Browse the repository at this point in the history
  • Loading branch information
bluss committed Dec 1, 2018
1 parent 8fde766 commit e14cac1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
1 change: 0 additions & 1 deletion benches/par_rayon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

extern crate rayon;

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

Expand Down
3 changes: 3 additions & 0 deletions src/parallel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,12 @@ pub mod prelude {
#[doc(no_inline)]
pub use rayon::prelude::{ParallelIterator, IndexedParallelIterator,
IntoParallelIterator, IntoParallelRefIterator, IntoParallelRefMutIterator};

pub use super::par_azip;
}

pub use self::par::Parallel;
pub use par_azip;

mod par;
mod ext_traits;
Expand Down
24 changes: 12 additions & 12 deletions src/parallel/zipmacro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
/// ## Examples
///
/// ```rust
/// #[macro_use(par_azip)]
/// extern crate ndarray;
///
/// use ndarray::Array2;
/// use ndarray::parallel::par_azip;
///
/// type M = Array2<f32>;
///
Expand All @@ -53,11 +53,11 @@
macro_rules! par_azip {
// Build Zip Rule (index)
(@parse [index => $a:expr, $($aa:expr,)*] $t1:tt in $t2:tt) => {
par_azip!(@finish ($crate::Zip::indexed($a)) [$($aa,)*] $t1 in $t2)
$crate::par_azip!(@finish ($crate::Zip::indexed($a)) [$($aa,)*] $t1 in $t2)
};
// Build Zip Rule (no index)
(@parse [$a:expr, $($aa:expr,)*] $t1:tt in $t2:tt) => {
par_azip!(@finish ($crate::Zip::from($a)) [$($aa,)*] $t1 in $t2)
$crate::par_azip!(@finish ($crate::Zip::from($a)) [$($aa,)*] $t1 in $t2)
};
// Build Finish Rule (both)
(@finish ($z:expr) [$($aa:expr,)*] [$($p:pat,)+] in { $($t:tt)*}) => {
Expand All @@ -74,31 +74,31 @@ macro_rules! par_azip {
// parsing stack: [expressions] [patterns] (one per operand)
// index uses empty [] -- must be first
(@parse [] [] index $i:pat, $($t:tt)*) => {
par_azip!(@parse [index =>] [$i,] $($t)*);
$crate::par_azip!(@parse [index =>] [$i,] $($t)*);
};
(@parse [$($exprs:tt)*] [$($pats:tt)*] mut $x:ident ($e:expr) $($t:tt)*) => {
par_azip!(@parse [$($exprs)* $e,] [$($pats)* mut $x,] $($t)*);
$crate::par_azip!(@parse [$($exprs)* $e,] [$($pats)* mut $x,] $($t)*);
};
(@parse [$($exprs:tt)*] [$($pats:tt)*] mut $x:ident $($t:tt)*) => {
par_azip!(@parse [$($exprs)* &mut $x,] [$($pats)* mut $x,] $($t)*);
$crate::par_azip!(@parse [$($exprs)* &mut $x,] [$($pats)* mut $x,] $($t)*);
};
(@parse [$($exprs:tt)*] [$($pats:tt)*] , $($t:tt)*) => {
par_azip!(@parse [$($exprs)*] [$($pats)*] $($t)*);
$crate::par_azip!(@parse [$($exprs)*] [$($pats)*] $($t)*);
};
(@parse [$($exprs:tt)*] [$($pats:tt)*] ref $x:ident ($e:expr) $($t:tt)*) => {
par_azip!(@parse [$($exprs)* $e,] [$($pats)* $x,] $($t)*);
$crate::par_azip!(@parse [$($exprs)* $e,] [$($pats)* $x,] $($t)*);
};
(@parse [$($exprs:tt)*] [$($pats:tt)*] ref $x:ident $($t:tt)*) => {
par_azip!(@parse [$($exprs)* &$x,] [$($pats)* $x,] $($t)*);
$crate::par_azip!(@parse [$($exprs)* &$x,] [$($pats)* $x,] $($t)*);
};
(@parse [$($exprs:tt)*] [$($pats:tt)*] $x:ident ($e:expr) $($t:tt)*) => {
par_azip!(@parse [$($exprs)* $e,] [$($pats)* &$x,] $($t)*);
$crate::par_azip!(@parse [$($exprs)* $e,] [$($pats)* &$x,] $($t)*);
};
(@parse [$($exprs:tt)*] [$($pats:tt)*] $x:ident $($t:tt)*) => {
par_azip!(@parse [$($exprs)* &$x,] [$($pats)* &$x,] $($t)*);
$crate::par_azip!(@parse [$($exprs)* &$x,] [$($pats)* &$x,] $($t)*);
};
(@parse [$($exprs:tt)*] [$($pats:tt)*] $($t:tt)*) => { };
($($t:tt)*) => {
par_azip!(@parse [] [] $($t)*);
$crate::par_azip!(@parse [] [] $($t)*);
}
}

0 comments on commit e14cac1

Please sign in to comment.