Skip to content

Commit 947b52b

Browse files
authored
Merge branch 'master' into mean-fromprimitive
2 parents ed24fad + e1a6db8 commit 947b52b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+2342
-738
lines changed

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,23 @@ sudo: required
44
dist: trusty
55
matrix:
66
include:
7-
- rust: 1.27.0
7+
- rust: 1.30.0
88
env:
99
- FEATURES='test docs'
1010
- rust: stable
1111
env:
1212
- FEATURES='test docs'
13-
- CARGO_INCREMENTAL=0
1413
- rust: beta
1514
env:
1615
- FEATURES='test docs'
17-
- CARGO_INCREMENTAL=0
1816
- rust: nightly
1917
env:
2018
- FEATURES='test docs'
2119
- IS_NIGHTLY=1
22-
- CARGO_INCREMENTAL=0
20+
env:
21+
global:
22+
- HOST=x86_64-unknown-linux-gnu
23+
- CARGO_INCREMENTAL=0
2324
branches:
2425
only:
2526
- master

Cargo.toml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
[package]
22

33
name = "ndarray"
4-
version = "0.12.0"
5-
authors = ["bluss"]
4+
version = "0.12.1"
5+
authors = [
6+
"bluss",
7+
"Jim Turner"
8+
]
69
license = "MIT/Apache-2.0"
710
readme = "README-crates.io.md"
811

9-
repository = "https://github.com/bluss/ndarray"
12+
repository = "https://github.com/rust-ndarray/ndarray"
1013
documentation = "https://docs.rs/ndarray/"
1114

1215
description = "An n-dimensional array for general elements and for numerics. Lightweight array views and slicing; views support chunking and splitting."
@@ -33,12 +36,13 @@ itertools = { version = "0.7.0", default-features = false }
3336
cblas-sys = { version = "0.1.4", optional = true, default-features = false }
3437
blas-src = { version = "0.2.0", optional = true, default-features = false }
3538

36-
matrixmultiply = { version = "0.1.13" }
39+
matrixmultiply = { version = "0.2.0" }
3740
# Use via the `serde-1` crate feature!
3841
serde = { version = "1.0", optional = true }
3942

4043
[dev-dependencies]
41-
defmac = "0.1"
44+
defmac = "0.2"
45+
quickcheck = { version = "0.7.2", default-features = false }
4246
rawpointer = "0.1"
4347

4448
[features]

LICENSE-MIT

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
Copyright (c) 2015
1+
Copyright (c) 2015 - 2018 Ulrik Sverdrup "bluss",
2+
Jim Turner,
3+
and ndarray developers
24

35
Permission is hereby granted, free of charge, to any
46
person obtaining a copy of this software and associated

README.rst

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ __ https://docs.rs/ndarray/
1010

1111
|build_status|_ |crates|_
1212

13-
.. |build_status| image:: https://api.travis-ci.org/bluss/ndarray.svg?branch=master
14-
.. _build_status: https://travis-ci.org/bluss/ndarray
13+
.. |build_status| image:: https://api.travis-ci.org/rust-ndarray/ndarray.svg?branch=master
14+
.. _build_status: https://travis-ci.org/rust-ndarray/ndarray
1515

1616
.. |crates| image:: http://meritbadge.herokuapp.com/ndarray
1717
.. _crates: https://crates.io/crates/ndarray
@@ -70,7 +70,7 @@ How to use with cargo
7070
::
7171

7272
[dependencies]
73-
ndarray = "0.11.0"
73+
ndarray = "0.12.1"
7474

7575
How to enable blas integration. Depend on ``blas-src`` directly to pick a blas
7676
provider. Depend on the same ``blas-src`` version as ``ndarray`` does, for the
@@ -80,14 +80,46 @@ provider::
8080

8181

8282
[dependencies]
83-
ndarray = { version = "0.11.0", features = ["blas"] }
83+
ndarray = { version = "0.12.1", features = ["blas"] }
8484
blas-src = { version = "0.2.0", default-features = false, features = ["openblas"] }
8585
openblas-src = { version = "0.6.0", default-features = false, features = ["cblas", "system"] }
8686

8787

8888
Recent Changes (ndarray)
8989
------------------------
9090

91+
- 0.12.1
92+
93+
- Add ``std_axis`` method for computing standard deviation by @LukeMathWalker.
94+
- Add ``product`` method for computing product of elements in an array by @sebasv.
95+
- Add ``first`` and ``first_mut`` methods for getting the first element of an array.
96+
- Add ``into_scalar`` method for converting an ``Array0`` into its element.
97+
- Add ``insert_axis_inplace`` and ``index_axis_inplace`` methods for inserting and
98+
removing axes in dynamic-dimensional (``IxDyn``) arrays without taking ownership.
99+
- Add ``stride_of`` method for getting the stride of an axis.
100+
- Add public ``ndim`` and ``zeros`` methods to ``Dimension`` trait.
101+
- Rename ``scalar_sum`` to ``sum``, ``subview`` to ``index_axis``,
102+
``subview_mut`` to ``index_axis_mut``, ``subview_inplace`` to
103+
``collapse_axis``, ``into_subview`` to ``index_axis_move``, and
104+
``slice_inplace`` to ``slice_collapse`` (deprecating the old names,
105+
except for ``scalar_sum`` which will be in 0.13).
106+
- Deprecate ``remove_axis`` and fix soundness hole when removing a zero-length axis.
107+
- Implement ``Clone`` for ``LanesIter``.
108+
- Implement ``Debug``, ``Copy``, and ``Clone`` for ``FoldWhile``.
109+
- Relax constraints on ``sum_axis``, ``mean_axis``, and ``into_owned``.
110+
- Add number of dimensions (and whether it's const or dynamic) to array ``Debug`` format.
111+
- Allow merging axes with ``merge_axes`` when either axis length is ≤ 1.
112+
- Clarify and check more precise safety requirements for constructing arrays.
113+
This fixes undefined behavior in some edge cases. (See `#543`_.)
114+
- Fix ``is_standard_layout`` in some edge cases. (See `#543`_.)
115+
- Fix chunk sizes in ``axis_chunks_iter`` and ``axis_chunks_iter_mut`` when
116+
the stride is zero or the array element type is zero-sized by @bluss.
117+
- Improve documentation by @jturner314, @bluss, and @paulkernfeld.
118+
- Improve element iterators with implementations of ``Iterator::rfold``.
119+
- Miscellaneous internal implementation improvements by @jturner314 and @bluss.
120+
121+
.. _`#543`: https://github.com/rust-ndarray/ndarray/pull/543
122+
91123
- 0.12.0
92124

93125
- Add ``var_axis`` method for computing variance by @LukeMathWalker.
@@ -164,7 +196,7 @@ __ https://docs.rs/ndarray/0.11/ndarray/doc/ndarray_for_numpy_users/
164196
- Minimum required Rust version is 1.22.
165197

166198
__ https://jim.turner.link/pages/ndarray-0.11/
167-
.. _`#380`: https://github.com/bluss/rust-ndarray/pull/380
199+
.. _`#380`: https://github.com/rust-ndarray/ndarray/pull/380
168200

169201
- 0.10.13
170202

@@ -310,7 +342,7 @@ __ https://bluss.github.io//rust/2017/04/09/ndarray-0.9/
310342
- ``AxisChunksIter`` creation sped up and it implements ``Clone``.
311343
- Dimension mismatch in ``Zip`` has a better panic message.
312344

313-
__ https://bluss.github.io/rust-ndarray/master/ndarray/type.IxDyn.html
345+
__ https://docs.rs/ndarray/0.8.2/ndarray/type.IxDyn.html
314346

315347
- 0.8.1
316348

@@ -634,7 +666,7 @@ __ http://bluss.github.io/rust/2016/03/06/ndarray-0.4/
634666
- Remove deprecated module ``linalg`` (it was already mostly empty)
635667
- Deprecate free function ``zeros`` in favour of static method ``zeros``.
636668

637-
__ https://bluss.github.io/rust-ndarray/master/ndarray/struct.ArrayBase.html#arithmetic-operations
669+
__ https://docs.rs/ndarray/0.4.0-alpha.5/ndarray/struct.ArrayBase.html#arithmetic-operations
638670

639671
- 0.4.0-alpha.4
640672

benches/bench1.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#![allow(unused_imports)]
33

44
extern crate test;
5-
#[macro_use(s, azip)]
65
extern crate ndarray;
76

87
use ndarray::{
@@ -13,7 +12,7 @@ use ndarray::{
1312
Array2,
1413
Zip,
1514
};
16-
use ndarray::{arr0, arr1, arr2};
15+
use ndarray::{arr0, arr1, arr2, azip, s};
1716
use ndarray::ShapeBuilder;
1817

1918
use test::black_box;
@@ -174,55 +173,55 @@ fn iter_sum_2d_transpose_by_row(bench: &mut test::Bencher)
174173
}
175174

176175
#[bench]
177-
fn scalar_sum_2d_regular(bench: &mut test::Bencher)
176+
fn sum_2d_regular(bench: &mut test::Bencher)
178177
{
179178
let a = Array::<i32, _>::zeros((64, 64));
180179
let a = black_box(a);
181180
bench.iter(|| {
182-
a.scalar_sum()
181+
a.sum()
183182
});
184183
}
185184

186185
#[bench]
187-
fn scalar_sum_2d_cutout(bench: &mut test::Bencher)
186+
fn sum_2d_cutout(bench: &mut test::Bencher)
188187
{
189188
let a = Array::<i32, _>::zeros((66, 66));
190189
let av = a.slice(s![1..-1, 1..-1]);
191190
let a = black_box(av);
192191
bench.iter(|| {
193-
a.scalar_sum()
192+
a.sum()
194193
});
195194
}
196195

197196
#[bench]
198-
fn scalar_sum_2d_float(bench: &mut test::Bencher)
197+
fn sum_2d_float(bench: &mut test::Bencher)
199198
{
200199
let a = Array::<f32, _>::zeros((64, 64));
201200
let a = black_box(a.view());
202201
bench.iter(|| {
203-
a.scalar_sum()
202+
a.sum()
204203
});
205204
}
206205

207206
#[bench]
208-
fn scalar_sum_2d_float_cutout(bench: &mut test::Bencher)
207+
fn sum_2d_float_cutout(bench: &mut test::Bencher)
209208
{
210209
let a = Array::<f32, _>::zeros((66, 66));
211210
let av = a.slice(s![1..-1, 1..-1]);
212211
let a = black_box(av);
213212
bench.iter(|| {
214-
a.scalar_sum()
213+
a.sum()
215214
});
216215
}
217216

218217
#[bench]
219-
fn scalar_sum_2d_float_t_cutout(bench: &mut test::Bencher)
218+
fn sum_2d_float_t_cutout(bench: &mut test::Bencher)
220219
{
221220
let a = Array::<f32, _>::zeros((66, 66));
222221
let av = a.slice(s![1..-1, 1..-1]).reversed_axes();
223222
let a = black_box(av);
224223
bench.iter(|| {
225-
a.scalar_sum()
224+
a.sum()
226225
});
227226
}
228227

benches/chunks.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
extern crate test;
44
use test::Bencher;
55

6-
#[macro_use(azip)]
76
extern crate ndarray;
87
use ndarray::prelude::*;
98
use ndarray::NdProducer;
@@ -22,14 +21,14 @@ fn chunk2x2_iter_sum(bench: &mut Bencher)
2221
}
2322

2423
#[bench]
25-
fn chunk2x2_scalar_sum(bench: &mut Bencher)
24+
fn chunk2x2_sum(bench: &mut Bencher)
2625
{
2726
let a = Array::<f32, _>::zeros((256, 256));
2827
let chunksz = (2, 2);
2928
let mut sum = Array::zeros(a.exact_chunks(chunksz).raw_dim());
3029
bench.iter(|| {
3130
azip!(ref a (a.exact_chunks(chunksz)), mut sum in {
32-
*sum = a.scalar_sum();
31+
*sum = a.sum();
3332
});
3433
});
3534
}

benches/construct.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
extern crate test;
44
use test::Bencher;
55

6-
#[macro_use(s)]
76
extern crate ndarray;
87
use ndarray::prelude::*;
98

benches/higher-order.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ extern crate test;
55
use test::Bencher;
66
use test::black_box;
77

8-
#[macro_use(s)]
98
extern crate ndarray;
109
use ndarray::prelude::*;
1110

benches/iter.rs

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ use test::Bencher;
66
use test::black_box;
77
use rawpointer::PointerExt;
88

9-
#[macro_use(s, azip)]
109
extern crate ndarray;
1110
use ndarray::prelude::*;
1211
use ndarray::{Zip, FoldWhile};
12+
use ndarray::Slice;
1313

1414
#[bench]
1515
fn iter_sum_2d_regular(bench: &mut Bencher)
@@ -97,7 +97,7 @@ fn iter_filter_sum_2d_stride_f32(bench: &mut Bencher)
9797
const ZIPSZ: usize = 10_000;
9898

9999
#[bench]
100-
fn scalar_sum_3_std_zip1(bench: &mut Bencher)
100+
fn sum_3_std_zip1(bench: &mut Bencher)
101101
{
102102
let a = vec![1; ZIPSZ];
103103
let b = vec![1; ZIPSZ];
@@ -110,7 +110,7 @@ fn scalar_sum_3_std_zip1(bench: &mut Bencher)
110110
}
111111

112112
#[bench]
113-
fn scalar_sum_3_std_zip2(bench: &mut Bencher)
113+
fn sum_3_std_zip2(bench: &mut Bencher)
114114
{
115115
let a = vec![1; ZIPSZ];
116116
let b = vec![1; ZIPSZ];
@@ -123,7 +123,7 @@ fn scalar_sum_3_std_zip2(bench: &mut Bencher)
123123
}
124124

125125
#[bench]
126-
fn scalar_sum_3_std_zip3(bench: &mut Bencher)
126+
fn sum_3_std_zip3(bench: &mut Bencher)
127127
{
128128
let a = vec![1; ZIPSZ];
129129
let b = vec![1; ZIPSZ];
@@ -151,7 +151,7 @@ fn vector_sum_3_std_zip(bench: &mut Bencher)
151151
}
152152

153153
#[bench]
154-
fn scalar_sum_3_azip(bench: &mut Bencher)
154+
fn sum_3_azip(bench: &mut Bencher)
155155
{
156156
let a = vec![1; ZIPSZ];
157157
let b = vec![1; ZIPSZ];
@@ -166,7 +166,7 @@ fn scalar_sum_3_azip(bench: &mut Bencher)
166166
}
167167

168168
#[bench]
169-
fn scalar_sum_3_azip_fold(bench: &mut Bencher)
169+
fn sum_3_azip_fold(bench: &mut Bencher)
170170
{
171171
let a = vec![1; ZIPSZ];
172172
let b = vec![1; ZIPSZ];
@@ -342,3 +342,51 @@ fn indexed_iter_3d_dyn(bench: &mut Bencher) {
342342
}
343343
})
344344
}
345+
346+
#[bench]
347+
fn iter_sum_1d_strided_fold(bench: &mut Bencher)
348+
{
349+
let mut a = Array::<u64, _>::ones(10240);
350+
a.slice_axis_inplace(Axis(0), Slice::new(0, None, 2));
351+
bench.iter(|| {
352+
a.iter().fold(0, |acc, &x| acc + x)
353+
});
354+
}
355+
356+
#[bench]
357+
fn iter_sum_1d_strided_rfold(bench: &mut Bencher)
358+
{
359+
let mut a = Array::<u64, _>::ones(10240);
360+
a.slice_axis_inplace(Axis(0), Slice::new(0, None, 2));
361+
bench.iter(|| {
362+
a.iter().rfold(0, |acc, &x| acc + x)
363+
});
364+
}
365+
366+
367+
#[bench]
368+
fn iter_axis_iter_sum(bench: &mut Bencher)
369+
{
370+
let a = Array::<f32, _>::zeros((64, 64));
371+
bench.iter(|| {
372+
a.axis_iter(Axis(0)).map(|plane| plane.sum()).sum::<f32>()
373+
});
374+
}
375+
376+
#[bench]
377+
fn iter_axis_chunks_1_iter_sum(bench: &mut Bencher)
378+
{
379+
let a = Array::<f32, _>::zeros((64, 64));
380+
bench.iter(|| {
381+
a.axis_chunks_iter(Axis(0), 1).map(|plane| plane.sum()).sum::<f32>()
382+
});
383+
}
384+
385+
#[bench]
386+
fn iter_axis_chunks_5_iter_sum(bench: &mut Bencher)
387+
{
388+
let a = Array::<f32, _>::zeros((64, 64));
389+
bench.iter(|| {
390+
a.axis_chunks_iter(Axis(0), 5).map(|plane| plane.sum()).sum::<f32>()
391+
});
392+
}

0 commit comments

Comments
 (0)