Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
4bdd185
Add examples of binary arithmetic operators (#589)
jturner314 Mar 11, 2019
869d3a9
Improve documentation for sum_axis and mean_axis
JP-Ellis Mar 20, 2019
b490cd7
Merge pull request #601 from JP-Ellis/improve-documentation
jturner314 Mar 20, 2019
20d372a
Enlarge parentheses in math in std_axis docs (#604)
jturner314 Mar 22, 2019
fe4365c
Implemented a function for smarter debug formatting.
Mar 24, 2019
2450f50
Fixed existing tests
Mar 24, 2019
19a09ca
Improve docs of .raw_dim(), .shape(), and .strides() (#591)
jturner314 Mar 25, 2019
c569f75
Add docs about nested `Vec`s/`Array`s
jturner314 Mar 25, 2019
3298cd5
Add mean method
LukeMathWalker Jan 10, 2019
6e37c46
Make mean_axis return Option, like mean does
LukeMathWalker Jan 10, 2019
64b3da7
Move numeric tests into the numeric test submodule
Jan 14, 2019
47b2691
Merge pull request #580 from LukeMathWalker/mean
jturner314 Mar 26, 2019
3474d3f
Some fixes:
Mar 26, 2019
2a8a7c7
Implemented axis shrinking for n-dim arrays
Mar 26, 2019
1b5da67
All the PR issues are fixed. Tests are needed.
Mar 27, 2019
fbf8cac
Fixed the tests
Mar 27, 2019
51c4e11
Added tests for 1- and 2-dimensional array with overflow
Mar 27, 2019
0d11708
Try to fix 1.31 build failing
Mar 27, 2019
18c868a
PRINT_ELEMENTS_LIMIT is now private
Mar 28, 2019
2924f2e
Support zero-length `axis` in `.map_axis/_mut()` (#612)
Apr 9, 2019
b36f56a
Implement Zip::all()
mneumann Apr 10, 2019
48275c4
Enhance documentation and test cases for Zip::all()
mneumann Apr 13, 2019
3aa8abe
Remove dead code
LukeMathWalker Apr 16, 2019
17f86bb
Rename format_array_v2 to format_array
LukeMathWalker Apr 16, 2019
d48c5a9
Simplify code using ndim
LukeMathWalker Apr 16, 2019
6c636dc
Access last element directly
LukeMathWalker Apr 16, 2019
88d53e3
Add a test to specify behaviour for zero-dimensional arrays
LukeMathWalker Apr 16, 2019
b962a7b
Add a test for empty arrays
LukeMathWalker Apr 16, 2019
29a8f70
Test zero-length axes
LukeMathWalker Apr 16, 2019
27c4a92
We already know that ndim > 0
LukeMathWalker Apr 16, 2019
49b4338
Merge pull request #2 from LukeMathWalker/smart-debug-formatting-review
Apr 17, 2019
b535f28
Made the formatting logic more modular
Apr 17, 2019
f566d8c
Forward more iterator methods (#614)
Apr 19, 2019
2b8dcf3
Add safety check for size after broadcasting (#613)
jturner314 Apr 19, 2019
2a8a3b0
Simplify element access
Apr 20, 2019
5fd9b2f
Almost there
Apr 20, 2019
f60185c
Clone for the win
Apr 20, 2019
198d689
Cast to 1d array
Apr 20, 2019
c1036fb
First and last elements have to be special cased. Done for multidimen…
Apr 20, 2019
5336b10
Extract in a separate function
Apr 21, 2019
4fa8a62
Tests are passing
Apr 21, 2019
e659390
Minor improvements
Apr 21, 2019
0abff2a
Formatting
Apr 21, 2019
e049abd
Remove closure
Apr 23, 2019
83c9f08
Use custom enum
Apr 23, 2019
72e05d7
Merge pull request #3 from LukeMathWalker/refactoring-smarter-debugging
Apr 23, 2019
44bf8b8
Merge pull request #615 from mneumann/zip_all
LukeMathWalker Apr 25, 2019
61b4835
Merge pull request #606 from andrei-papou/smart-debug-formatting
LukeMathWalker Apr 26, 2019
3656ddf
Add `logspace` and `geomspace` constructors (#617)
JP-Ellis May 4, 2019
966809a
Merge branch 'master' into update-approx
LukeMathWalker May 4, 2019
cbb07a4
Use Zip::all where possible
LukeMathWalker May 4, 2019
d21fe5c
Mark `all_close` as deprecated
LukeMathWalker May 4, 2019
5e30924
Fix implementation.
LukeMathWalker May 4, 2019
fa60376
Fix issues with conditional execution based on activated features
LukeMathWalker May 4, 2019
8fb8aa4
Remove all_close from all doc tests
LukeMathWalker May 4, 2019
3e47c5c
Update guide for NumPy users
LukeMathWalker May 4, 2019
9b83175
Replace all_close with abs_diff_eq in tests (currently failing)
LukeMathWalker May 4, 2019
e0f390d
Fix typo, pin 0.3.2 to get latest changes
LukeMathWalker May 4, 2019
ac67ea5
Allow comparison between arrays with different ownership properties
LukeMathWalker May 5, 2019
35915b8
Fix assertions
LukeMathWalker May 5, 2019
3d81967
Fix test
LukeMathWalker May 5, 2019
cf646e2
Move tests from all_close to approx
LukeMathWalker May 5, 2019
e6c6ff1
Move tests from all_close to approx
LukeMathWalker May 5, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ itertools = { version = "0.7.0", default-features = false }

rayon = { version = "1.0.3", optional = true }

approx = { version = "0.3", optional = true }
approx = { version = "0.3.2", optional = true }

# Use via the `blas` crate feature!
cblas-sys = { version = "0.1.4", optional = true, default-features = false }
Expand All @@ -49,6 +49,8 @@ serde = { version = "1.0", optional = true }
defmac = "0.2"
quickcheck = { version = "0.7.2", default-features = false }
rawpointer = "0.1"
itertools = { version = "0.7.0", default-features = false, features = ["use_std"] }
approx = "0.3.2"

[features]
# Enable blas usage
Expand Down
4 changes: 2 additions & 2 deletions examples/column_standardize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ fn main() {
[ 2., 2., 2.]];

println!("{:8.4}", data);
println!("{:8.4} (Mean axis=0)", data.mean_axis(Axis(0)));
println!("{:8.4} (Mean axis=0)", data.mean_axis(Axis(0)).unwrap());

data -= &data.mean_axis(Axis(0));
data -= &data.mean_axis(Axis(0)).unwrap();
println!("{:8.4}", data);

data /= &std(&data, Axis(0));
Expand Down
44 changes: 13 additions & 31 deletions src/array_approx.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use crate::imp_prelude::*;
use crate::{FoldWhile, Zip};
use crate::Zip;
use approx::{AbsDiffEq, RelativeEq, UlpsEq};

/// **Requires crate feature `"approx"`**
impl<A, S, D> AbsDiffEq for ArrayBase<S, D>
impl<A, S, T, D> AbsDiffEq<ArrayBase<T, D>> for ArrayBase<S, D>
where
A: AbsDiffEq,
A::Epsilon: Clone,
S: Data<Elem = A>,
T: Data<Elem = A>,
D: Dimension,
{
type Epsilon = A::Epsilon;
Expand All @@ -16,29 +17,23 @@ where
A::default_epsilon()
}

fn abs_diff_eq(&self, other: &ArrayBase<S, D>, epsilon: A::Epsilon) -> bool {
fn abs_diff_eq(&self, other: &ArrayBase<T, D>, epsilon: A::Epsilon) -> bool {
if self.shape() != other.shape() {
return false;
}
Zip::from(self)
.and(other)
.fold_while(true, |_, a, b| {
if A::abs_diff_ne(a, b, epsilon.clone()) {
FoldWhile::Done(false)
} else {
FoldWhile::Continue(true)
}
})
.into_inner()
.all(|a, b| A::abs_diff_eq(a, b, epsilon.clone()))
}
}

/// **Requires crate feature `"approx"`**
impl<A, S, D> RelativeEq for ArrayBase<S, D>
impl<A, S, T, D> RelativeEq<ArrayBase<T, D>> for ArrayBase<S, D>
where
A: RelativeEq,
A::Epsilon: Clone,
S: Data<Elem = A>,
T: Data<Elem = A>,
D: Dimension,
{
fn default_max_relative() -> A::Epsilon {
Expand All @@ -47,7 +42,7 @@ where

fn relative_eq(
&self,
other: &ArrayBase<S, D>,
other: &ArrayBase<T, D>,
epsilon: A::Epsilon,
max_relative: A::Epsilon,
) -> bool {
Expand All @@ -56,43 +51,30 @@ where
}
Zip::from(self)
.and(other)
.fold_while(true, |_, a, b| {
if A::relative_ne(a, b, epsilon.clone(), max_relative.clone()) {
FoldWhile::Done(false)
} else {
FoldWhile::Continue(true)
}
})
.into_inner()
.all(|a, b| A::relative_eq(a, b, epsilon.clone(), max_relative.clone()))
}
}

/// **Requires crate feature `"approx"`**
impl<A, S, D> UlpsEq for ArrayBase<S, D>
impl<A, S, D, T> UlpsEq<ArrayBase<T, D>> for ArrayBase<S, D>
where
A: UlpsEq,
A::Epsilon: Clone,
S: Data<Elem = A>,
T: Data<Elem = A>,
D: Dimension,
{
fn default_max_ulps() -> u32 {
A::default_max_ulps()
}

fn ulps_eq(&self, other: &ArrayBase<S, D>, epsilon: A::Epsilon, max_ulps: u32) -> bool {
fn ulps_eq(&self, other: &ArrayBase<T, D>, epsilon: A::Epsilon, max_ulps: u32) -> bool {
if self.shape() != other.shape() {
return false;
}
Zip::from(self)
.and(other)
.fold_while(true, |_, a, b| {
if A::ulps_ne(a, b, epsilon.clone(), max_ulps) {
FoldWhile::Done(false)
} else {
FoldWhile::Continue(true)
}
})
.into_inner()
.all(|a, b| A::ulps_eq(a, b, epsilon.clone(), max_ulps))
}
}

Expand Down
Loading