Skip to content

Commit 3557a8d

Browse files
committed
Update syntax everywhere
1 parent 4a63647 commit 3557a8d

File tree

10 files changed

+19
-19
lines changed

10 files changed

+19
-19
lines changed

README-quick-start.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn main() {
9191
use ndarray::prelude::*;
9292
use ndarray::{Array, Ix3};
9393
fn main() {
94-
let a = Array::<f64, _>::linspace(0., 5., 11);
94+
let a = Array::<f64, _>::linspace(0.0..5.0, 11);
9595
println!("{:?}", a);
9696
}
9797
```

benches/bench1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ const MEAN_SUM_N: usize = 127;
984984
fn range_mat(m: Ix, n: Ix) -> Array2<f32>
985985
{
986986
assert!(m * n != 0);
987-
Array::linspace(0., (m * n - 1) as f32, m * n)
987+
Array::linspace(0.0..(m * n - 1) as f32, m * n)
988988
.into_shape_with_order((m, n))
989989
.unwrap()
990990
}

benches/higher-order.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const Y: usize = 16;
1414
#[bench]
1515
fn map_regular(bench: &mut Bencher)
1616
{
17-
let a = Array::linspace(0., 127., N)
17+
let a = Array::linspace(0.0..127.0, N)
1818
.into_shape_with_order((X, Y))
1919
.unwrap();
2020
bench.iter(|| a.map(|&x| 2. * x));
@@ -29,7 +29,7 @@ pub fn double_array(mut a: ArrayViewMut2<'_, f64>)
2929
#[bench]
3030
fn map_stride_double_f64(bench: &mut Bencher)
3131
{
32-
let mut a = Array::linspace(0., 127., N * 2)
32+
let mut a = Array::linspace(0.0..127.0, N * 2)
3333
.into_shape_with_order([X, Y * 2])
3434
.unwrap();
3535
let mut av = a.slice_mut(s![.., ..;2]);
@@ -42,7 +42,7 @@ fn map_stride_double_f64(bench: &mut Bencher)
4242
#[bench]
4343
fn map_stride_f64(bench: &mut Bencher)
4444
{
45-
let a = Array::linspace(0., 127., N * 2)
45+
let a = Array::linspace(0.0..127.0, N * 2)
4646
.into_shape_with_order([X, Y * 2])
4747
.unwrap();
4848
let av = a.slice(s![.., ..;2]);
@@ -53,7 +53,7 @@ fn map_stride_f64(bench: &mut Bencher)
5353
#[bench]
5454
fn map_stride_u32(bench: &mut Bencher)
5555
{
56-
let a = Array::linspace(0., 127., N * 2)
56+
let a = Array::linspace(0.0..127.0, N * 2)
5757
.into_shape_with_order([X, Y * 2])
5858
.unwrap();
5959
let b = a.mapv(|x| x as u32);
@@ -65,7 +65,7 @@ fn map_stride_u32(bench: &mut Bencher)
6565
#[bench]
6666
fn fold_axis(bench: &mut Bencher)
6767
{
68-
let a = Array::linspace(0., 127., N * 2)
68+
let a = Array::linspace(0.0..127.0, N * 2)
6969
.into_shape_with_order([X, Y * 2])
7070
.unwrap();
7171
bench.iter(|| a.fold_axis(Axis(0), 0., |&acc, &elt| acc + elt));

benches/numeric.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const Y: usize = 16;
1313
#[bench]
1414
fn clip(bench: &mut Bencher)
1515
{
16-
let mut a = Array::linspace(0., 127., N * 2)
16+
let mut a = Array::linspace(0.0..127.0, N * 2)
1717
.into_shape_with_order([X, Y * 2])
1818
.unwrap();
1919
let min = 2.;

examples/sort-axis.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ where D: Dimension
169169
#[cfg(feature = "std")]
170170
fn main()
171171
{
172-
let a = Array::linspace(0., 63., 64)
172+
let a = Array::linspace(0.0..63.0, 64)
173173
.into_shape_with_order((8, 8))
174174
.unwrap();
175175
let strings = a.map(|x| x.to_string());

src/doc/ndarray_for_numpy_users/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@
195195
//! ------|-----------|------
196196
//! `np.array([[1.,2.,3.], [4.,5.,6.]])` | [`array![[1.,2.,3.], [4.,5.,6.]]`][array!] or [`arr2(&[[1.,2.,3.], [4.,5.,6.]])`][arr2()] | 2×3 floating-point array literal
197197
//! `np.arange(0., 10., 0.5)` or `np.r_[:10.:0.5]` | [`Array::range(0., 10., 0.5)`][::range()] | create a 1-D array with values `0.`, `0.5`, …, `9.5`
198-
//! `np.linspace(0., 10., 11)` or `np.r_[:10.:11j]` | [`Array::linspace(0., 10., 11)`][::linspace()] | create a 1-D array with 11 elements with values `0.`, …, `10.`
199-
//! `np.logspace(2.0, 3.0, num=4, base=10.0)` | [`Array::logspace(10.0, 2.0, 3.0, 4)`][::logspace()] | create a 1-D array with 4 elements with values `100.`, `215.4`, `464.1`, `1000.`
198+
//! `np.linspace(0., 10., 11)` or `np.r_[:10.:11j]` | [`Array::linspace(0.0..=10.0, 11)`][::linspace()] | create a 1-D array with 11 elements with values `0.`, …, `10.`
199+
//! `np.logspace(2.0, 3.0, num=4, base=10.0)` | [`Array::logspace(10.0, 2.0..=3.0, 4)`][::logspace()] | create a 1-D array with 4 elements with values `100.`, `215.4`, `464.1`, `1000.`
200200
//! `np.geomspace(1., 1000., num=4)` | [`Array::geomspace(1e0, 1e3, 4)`][::geomspace()] | create a 1-D array with 4 elements with values `1.`, `10.`, `100.`, `1000.`
201201
//! `np.ones((3, 4, 5))` | [`Array::ones((3, 4, 5))`][::ones()] | create a 3×4×5 array filled with ones (inferring the element type)
202202
//! `np.zeros((3, 4, 5))` | [`Array::zeros((3, 4, 5))`][::zeros()] | create a 3×4×5 array filled with zeros (inferring the element type)

src/impl_constructors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ where S: DataOwned<Elem = A>
9292
/// ```rust
9393
/// use ndarray::{Array, arr1};
9494
///
95-
/// let array = Array::linspace(0., 1., 5);
95+
/// let array = Array::linspace(0.0..=1.0, 5);
9696
/// assert!(array == arr1(&[0.0, 0.25, 0.5, 0.75, 1.0]))
9797
/// ```
9898
#[cfg(feature = "std")]
@@ -136,10 +136,10 @@ where S: DataOwned<Elem = A>
136136
/// use approx::assert_abs_diff_eq;
137137
/// use ndarray::{Array, arr1};
138138
///
139-
/// let array = Array::logspace(10.0, 0.0, 3.0, 4);
139+
/// let array = Array::logspace(10.0, 0.0..=3.0, 4);
140140
/// assert_abs_diff_eq!(array, arr1(&[1e0, 1e1, 1e2, 1e3]), epsilon = 1e-12);
141141
///
142-
/// let array = Array::logspace(-10.0, 3.0, 0.0, 4);
142+
/// let array = Array::logspace(-10.0, 3.0..=0.0, 4);
143143
/// assert_abs_diff_eq!(array, arr1(&[-1e3, -1e2, -1e1, -1e0]), epsilon = 1e-12);
144144
/// # }
145145
/// ```

src/parallel/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
//! use ndarray::Axis;
6666
//! use ndarray::parallel::prelude::*;
6767
//!
68-
//! let a = Array::linspace(0., 63., 64).into_shape_with_order((4, 16)).unwrap();
68+
//! let a = Array::linspace(0.0..63.0, 64).into_shape_with_order((4, 16)).unwrap();
6969
//! let mut sums = Vec::new();
7070
//! a.axis_iter(Axis(0))
7171
//! .into_par_iter()
@@ -84,7 +84,7 @@
8484
//! use ndarray::Axis;
8585
//! use ndarray::parallel::prelude::*;
8686
//!
87-
//! let a = Array::linspace(0., 63., 64).into_shape_with_order((4, 16)).unwrap();
87+
//! let a = Array::linspace(0.0..63.0, 64).into_shape_with_order((4, 16)).unwrap();
8888
//! let mut shapes = Vec::new();
8989
//! a.axis_chunks_iter(Axis(0), 3)
9090
//! .into_par_iter()

tests/par_azip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fn test_par_azip3()
4141
*a += b / 10.;
4242
*c = a.sin();
4343
});
44-
let res = Array::linspace(0., 3.1, 32).mapv_into(f32::sin);
44+
let res = Array::linspace(0.0..3.1, 32).mapv_into(f32::sin);
4545
assert_abs_diff_eq!(res, ArrayView::from(&c), epsilon = 1e-4);
4646
}
4747

tests/par_rayon.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn test_axis_iter()
2626
fn test_axis_iter_mut()
2727
{
2828
use approx::assert_abs_diff_eq;
29-
let mut a = Array::linspace(0., 1.0f64, M * N)
29+
let mut a = Array::linspace(0.0..1.0f64, M * N)
3030
.into_shape_with_order((M, N))
3131
.unwrap();
3232
let b = a.mapv(|x| x.exp());
@@ -82,7 +82,7 @@ fn test_axis_chunks_iter()
8282
fn test_axis_chunks_iter_mut()
8383
{
8484
use approx::assert_abs_diff_eq;
85-
let mut a = Array::linspace(0., 1.0f64, M * N)
85+
let mut a = Array::linspace(0.0..1.0f64, M * N)
8686
.into_shape_with_order((M, N))
8787
.unwrap();
8888
let b = a.mapv(|x| x.exp());

0 commit comments

Comments
 (0)