Skip to content

Commit fc06f40

Browse files
committed
Fix errors related ndarray
1 parent ef564a2 commit fc06f40

File tree

3 files changed

+24
-33
lines changed

3 files changed

+24
-33
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ documentation = "https://docs.rs/csaps"
1313
readme = "README.md"
1414
license = "MIT"
1515

16-
edition = "2021"
16+
edition = "2018"
1717

1818

1919
[badges]

src/umv/evaluate.rs

+5-14
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
use ndarray::{
2-
Dimension,
3-
Axis,
4-
Array,
5-
Array1,
6-
Array2,
7-
ArrayView1,
8-
ArrayView2,
9-
s,
10-
stack,
11-
};
1+
use ndarray::{prelude::*, s, concatenate};
2+
123

134
use crate::{
145
Real,
@@ -35,12 +26,12 @@ impl<'a, T> NdSpline<'a, T>
3526
xi: ArrayView1<'a, T>) -> Array2<T>
3627
{
3728
let edges = {
38-
let mesh = breaks.slice(s![1..-1]);
29+
let mesh = breaks.slice(s![1 as i32..-1]);
3930
let one = Array1::<T>::ones((1, ));
4031
let left_bound = &one * T::neg_infinity();
4132
let right_bound = &one * T::infinity();
4233

43-
stack![Axis(0), left_bound, mesh, right_bound]
34+
concatenate![Axis(0), left_bound, mesh, right_bound]
4435
};
4536

4637
let mut indices = digitize(&xi, &edges);
@@ -68,7 +59,7 @@ impl<'a, T> NdSpline<'a, T>
6859
.map(coeffs_by_index)
6960
.collect();
7061

71-
stack(Axis(1), &indexed_coeffs).unwrap()
62+
concatenate(Axis(1), &indexed_coeffs).unwrap()
7263
};
7364

7465
// Vectorized computing the spline pieces (polynoms) on the given data sites

src/umv/make.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use ndarray::{prelude::*, stack};
1+
use ndarray::{prelude::*, stack, concatenate};
22

33
use crate::{
44
Real,
@@ -17,9 +17,9 @@ impl<'a, T, D> CubicSmoothingSpline<'a, T, D>
1717
{
1818
pub(super) fn make_spline(&mut self) -> Result<()> {
1919
let one = T::one();
20-
let two = T::from(2.0).unwrap();
21-
let three = T::from(3.0).unwrap();
22-
let six = T::from(6.0).unwrap();
20+
let two = T::from::<f64>(2.0).unwrap();
21+
let three = T::from::<f64>(3.0).unwrap();
22+
let six = T::from::<f64>(6.0).unwrap();
2323

2424
let breaks = self.x;
2525

@@ -41,8 +41,8 @@ impl<'a, T, D> CubicSmoothingSpline<'a, T, D>
4141
// The corner case for Nx2 data (2 data points)
4242
if pcount == 2 {
4343
drop(dx);
44-
let yi = y.slice(s![.., 0]).insert_axis(Axis(1));
45-
let coeffs = stack![Axis(1), dydx, yi];
44+
let yi = y.slice(s![.., 0 as usize]).insert_axis(Axis(1));
45+
let coeffs = concatenate![Axis(1), dydx, yi];
4646

4747
self.smooth = Some(one);
4848
self.spline = Some(NdSpline::new(breaks, coeffs));
@@ -56,11 +56,11 @@ impl<'a, T, D> CubicSmoothingSpline<'a, T, D>
5656
let qtwq = {
5757
let qt = {
5858
let odx = ones(pcount - 1) / &dx;
59-
let odx_head = odx.slice(s![..-1]).insert_axis(Axis(0)).into_owned();
60-
let odx_tail = odx.slice(s![1..]).insert_axis(Axis(0)).into_owned();
59+
let odx_head = odx.slice(s![..-1 as i32]).insert_axis(Axis(0)).into_owned();
60+
let odx_tail = odx.slice(s![1 as i32..]).insert_axis(Axis(0)).into_owned();
6161
drop(odx);
6262
let odx_body = -(&odx_tail + &odx_head);
63-
let diags_qt = stack![Axis(0), odx_head, odx_body, odx_tail];
63+
let diags_qt = concatenate![Axis(0), odx_head, odx_body, odx_tail];
6464

6565
sprsext::diags(diags_qt, &[0, 1, 2], (pcount - 2, pcount))
6666
};
@@ -76,10 +76,10 @@ impl<'a, T, D> CubicSmoothingSpline<'a, T, D>
7676
};
7777

7878
let r = {
79-
let dx_head = dx.slice(s![..-1]).insert_axis(Axis(0)).into_owned();
80-
let dx_tail = dx.slice(s![1..]).insert_axis(Axis(0)).into_owned();
79+
let dx_head = dx.slice(s![..-1 as i32]).insert_axis(Axis(0)).into_owned();
80+
let dx_tail = dx.slice(s![1 as i32..]).insert_axis(Axis(0)).into_owned();
8181
let dx_body = (&dx_tail + &dx_head) * two;
82-
let diags_r = stack![Axis(0), dx_tail, dx_body, dx_head];
82+
let diags_r = concatenate![Axis(0), dx_tail, dx_body, dx_head];
8383

8484
sprsext::diags(diags_r, &[-1, 0, 1], (pcount - 2, pcount - 2))
8585
};
@@ -109,11 +109,11 @@ impl<'a, T, D> CubicSmoothingSpline<'a, T, D>
109109
sprsext::solve(&a, &b)
110110
};
111111

112-
// Compute and stack spline coefficients
112+
// Compute and concatenatespline coefficients
113113
let coeffs = {
114114
let vpad = |arr: &Array2<T>| -> Array2<T> {
115115
let pad = Array2::<T>::zeros((1, arr.shape()[1]));
116-
stack(Axis(0), &[pad.view(), arr.view(), pad.view()]).unwrap()
116+
concatenate(Axis(0), &[pad.view(), arr.view(), pad.view()]).unwrap()
117117
};
118118

119119
let dx = dx.insert_axis(Axis(1));
@@ -133,17 +133,17 @@ impl<'a, T, D> CubicSmoothingSpline<'a, T, D>
133133
};
134134

135135
let c3 = vpad(&(usol * smooth));
136-
let c3_head = c3.slice(s![..-1, ..]);
137-
let c3_tail = c3.slice(s![1.., ..]);
136+
let c3_head = c3.slice(s![..-1 as i32, ..]);
137+
let c3_tail = c3.slice(s![1 as i32.., ..]);
138138

139139
let p1 = diff(&c3, Some(Axis(0))) / &dx;
140140
let p2 = &c3_head * three;
141141
let p3 = diff(&yi, Some(Axis(0))) / &dx - (&c3_head * two + c3_tail) * dx;
142-
let p4 = yi.slice(s![..-1, ..]);
142+
let p4 = yi.view().slice(s![..-1 as i32, ..]);
143143

144144
drop(c3);
145145

146-
stack![Axis(0), p1, p2, p3, p4].t().to_owned()
146+
concatenate(Axis(0), &[p1.view(), p2.view(), p3.view(), p4]).unwrap().t().to_owned()
147147
};
148148

149149
self.smooth = Some(smooth);

0 commit comments

Comments
 (0)