fix clippy lints
This commit is contained in:
		@@ -236,7 +236,7 @@ impl Field {
 | 
			
		||||
        &mut self,
 | 
			
		||||
        x: ArrayView2<Float>,
 | 
			
		||||
        y: ArrayView2<Float>,
 | 
			
		||||
        t: Float,
 | 
			
		||||
        time: Float,
 | 
			
		||||
        vortex_param: VortexParameters,
 | 
			
		||||
    ) {
 | 
			
		||||
        assert_eq!(x.shape(), y.shape());
 | 
			
		||||
@@ -253,7 +253,7 @@ impl Field {
 | 
			
		||||
            e.into_shape((n,)).unwrap(),
 | 
			
		||||
            x.into_shape((n,)).unwrap(),
 | 
			
		||||
            y.into_shape((n,)).unwrap(),
 | 
			
		||||
            t,
 | 
			
		||||
            time,
 | 
			
		||||
            vortex_param,
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
@@ -293,7 +293,7 @@ impl Field {
 | 
			
		||||
        );
 | 
			
		||||
        // Repeating to get the form
 | 
			
		||||
        // [[hx0, hx1, ..., hxn], [hx0, hx1, ..., hxn], ..., [hx0, hx1, ..., hxn]]
 | 
			
		||||
        let hxiterator = hxiterator.into_iter().cycle().take(self.nx() * self.ny());
 | 
			
		||||
        let hxiterator = hxiterator.cycle().take(self.nx() * self.ny());
 | 
			
		||||
 | 
			
		||||
        let hyiterator = itermaker(
 | 
			
		||||
            self.ny(),
 | 
			
		||||
@@ -305,14 +305,11 @@ impl Field {
 | 
			
		||||
        );
 | 
			
		||||
        // Repeating to get the form
 | 
			
		||||
        // [[hy0, hy0, ..., hy0], [hy1, hy1, ..., hy1], ..., [hym, hym, ..., hym]]
 | 
			
		||||
        let hyiterator = hyiterator
 | 
			
		||||
            .into_iter()
 | 
			
		||||
            .flat_map(|x| std::iter::repeat(x).take(self.nx()));
 | 
			
		||||
        let hyiterator = hyiterator.flat_map(|x| std::iter::repeat(x).take(self.nx()));
 | 
			
		||||
 | 
			
		||||
        let diagiterator = hxiterator.into_iter().zip(hyiterator).cycle();
 | 
			
		||||
        let diagiterator = hxiterator.zip(hyiterator).cycle();
 | 
			
		||||
 | 
			
		||||
        diagiterator
 | 
			
		||||
            .into_iter()
 | 
			
		||||
            .zip(self.0.iter())
 | 
			
		||||
            .zip(other.0.iter())
 | 
			
		||||
            .map(|(((hx, hy), r0), r1)| (*r0 - *r1).powi(2) * hx * hy)
 | 
			
		||||
@@ -344,6 +341,7 @@ pub struct VortexParameters {
 | 
			
		||||
    pub mach: Float,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[allow(clippy::too_many_arguments)]
 | 
			
		||||
pub fn vortex(
 | 
			
		||||
    rho: ArrayViewMut1<Float>,
 | 
			
		||||
    rhou: ArrayViewMut1<Float>,
 | 
			
		||||
@@ -351,7 +349,7 @@ pub fn vortex(
 | 
			
		||||
    e: ArrayViewMut1<Float>,
 | 
			
		||||
    x: ArrayView1<Float>,
 | 
			
		||||
    y: ArrayView1<Float>,
 | 
			
		||||
    t: Float,
 | 
			
		||||
    time: Float,
 | 
			
		||||
    vortex_param: VortexParameters,
 | 
			
		||||
) {
 | 
			
		||||
    assert_eq!(rho.len(), rhou.len());
 | 
			
		||||
@@ -374,7 +372,7 @@ pub fn vortex(
 | 
			
		||||
    {
 | 
			
		||||
        use crate::consts::PI;
 | 
			
		||||
 | 
			
		||||
        let dx = (x - vortex_param.x0) - t;
 | 
			
		||||
        let dx = (x - vortex_param.x0) - time;
 | 
			
		||||
        let dy = y - vortex_param.y0;
 | 
			
		||||
        let f = (1.0 - (dx*dx + dy*dy))/(rstar*rstar);
 | 
			
		||||
 | 
			
		||||
@@ -791,8 +789,8 @@ impl BoundaryStorage {
 | 
			
		||||
fn vortexify(
 | 
			
		||||
    mut field: ndarray::ArrayViewMut2<Float>,
 | 
			
		||||
    yx: (ndarray::ArrayView1<Float>, ndarray::ArrayView1<Float>),
 | 
			
		||||
    v: VortexParameters,
 | 
			
		||||
    t: Float,
 | 
			
		||||
    vparams: VortexParameters,
 | 
			
		||||
    time: Float,
 | 
			
		||||
) {
 | 
			
		||||
    let mut fiter = field.outer_iter_mut();
 | 
			
		||||
    let (rho, rhou, rhov, e) = (
 | 
			
		||||
@@ -802,7 +800,7 @@ fn vortexify(
 | 
			
		||||
        fiter.next().unwrap(),
 | 
			
		||||
    );
 | 
			
		||||
    let (y, x) = yx;
 | 
			
		||||
    vortex(rho, rhou, rhov, e, x, y, t, v);
 | 
			
		||||
    vortex(rho, rhou, rhov, e, x, y, time, vparams);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[allow(non_snake_case)]
 | 
			
		||||
 
 | 
			
		||||
@@ -36,7 +36,9 @@ impl ButcherTableau for MidpointMethod {
 | 
			
		||||
    const C: &'static [Float] = &[1.0 / 2.0];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Bit exessive...
 | 
			
		||||
/// Bit excessive...
 | 
			
		||||
#[allow(clippy::excessive_precision)]
 | 
			
		||||
#[allow(clippy::unreadable_literal)]
 | 
			
		||||
const SQRT_5: Float = 2.236067977499789696409173668731276235440618359611525724270897245410520925637804899414414408378782275;
 | 
			
		||||
pub struct Rk6;
 | 
			
		||||
impl ButcherTableau for Rk6 {
 | 
			
		||||
@@ -85,6 +87,7 @@ impl ButcherTableau for Rk6 {
 | 
			
		||||
    ];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[allow(clippy::too_many_arguments)]
 | 
			
		||||
pub fn integrate<'a, BTableau, F: 'a, RHS, MT, C>(
 | 
			
		||||
    rhs: RHS,
 | 
			
		||||
    prev: &F,
 | 
			
		||||
@@ -142,6 +145,7 @@ pub fn integrate<'a, BTableau, F: 'a, RHS, MT, C>(
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[cfg(feature = "rayon")]
 | 
			
		||||
#[allow(clippy::too_many_arguments)]
 | 
			
		||||
pub fn integrate_multigrid<'a, BTableau, F: 'a, RHS, MT, C>(
 | 
			
		||||
    rhs: RHS,
 | 
			
		||||
    prev: &[F],
 | 
			
		||||
 
 | 
			
		||||
@@ -40,7 +40,7 @@ pub fn json_to_grids(json: JsonValue) -> Result<Vec<ExtendedGrid>, String> {
 | 
			
		||||
            Array2(ndarray::Array2<Float>),
 | 
			
		||||
        }
 | 
			
		||||
        if grid.is_empty() {
 | 
			
		||||
            return Err(format!("empty object"));
 | 
			
		||||
            return Err("empty object".to_string());
 | 
			
		||||
        }
 | 
			
		||||
        let name = grid.remove("name").take_string();
 | 
			
		||||
        let dire = grid.remove("dirE").take_string();
 | 
			
		||||
@@ -76,7 +76,7 @@ pub fn json_to_grids(json: JsonValue) -> Result<Vec<ExtendedGrid>, String> {
 | 
			
		||||
                        None => return Err(format!("")),
 | 
			
		||||
                    };
 | 
			
		||||
                    if iter.next().is_some() {
 | 
			
		||||
                        return Err(format!("linspace: contained more than expected"));
 | 
			
		||||
                        return Err("linspace: contained more than expected".to_string());
 | 
			
		||||
                    }
 | 
			
		||||
                    Ok(ArrayForm::Array1(if h2 {
 | 
			
		||||
                        h2linspace(start, end, steps)
 | 
			
		||||
@@ -84,29 +84,29 @@ pub fn json_to_grids(json: JsonValue) -> Result<Vec<ExtendedGrid>, String> {
 | 
			
		||||
                        ndarray::Array::linspace(start, end, steps)
 | 
			
		||||
                    }))
 | 
			
		||||
                } else {
 | 
			
		||||
                    Err(format!("Could not parse gridline"))
 | 
			
		||||
                    Err("Could not parse gridline".to_string())
 | 
			
		||||
                }
 | 
			
		||||
            } else if x.is_array() {
 | 
			
		||||
                let arrlen = x.len();
 | 
			
		||||
                if arrlen == 0 {
 | 
			
		||||
                    return Err(format!("gridline does not have any members"));
 | 
			
		||||
                    return Err("gridline does not have any members".to_string());
 | 
			
		||||
                }
 | 
			
		||||
                if !x[0].is_array() {
 | 
			
		||||
                    let v = x
 | 
			
		||||
                        .members()
 | 
			
		||||
                        .map(|x: &JsonValue| -> Result<Float, String> {
 | 
			
		||||
                            Ok(x.as_number().ok_or_else(|| format!("Array contained something that could not be converted to an array"))?.into())
 | 
			
		||||
                            Ok(x.as_number().ok_or_else(|| "Array contained something that could not be converted to an array".to_string())?.into())
 | 
			
		||||
                        })
 | 
			
		||||
                        .collect::<Result<Vec<Float>, _>>()?;
 | 
			
		||||
                    Ok(ArrayForm::Array1(ndarray::Array::from(v)))
 | 
			
		||||
                } else {
 | 
			
		||||
                    let arrlen2 = x[0].len();
 | 
			
		||||
                    if arrlen2 == 0 {
 | 
			
		||||
                        return Err(format!("gridline does not have any members"));
 | 
			
		||||
                        return Err("gridline does not have any members".to_string());
 | 
			
		||||
                    }
 | 
			
		||||
                    for member in x.members() {
 | 
			
		||||
                        if arrlen2 != member.len() {
 | 
			
		||||
                            return Err(format!("some arrays seems to have differing lengths"));
 | 
			
		||||
                            return Err("some arrays seems to have differing lengths".to_string());
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    let mut arr = ndarray::Array::zeros((arrlen, arrlen2));
 | 
			
		||||
@@ -115,7 +115,7 @@ pub fn json_to_grids(json: JsonValue) -> Result<Vec<ExtendedGrid>, String> {
 | 
			
		||||
                            *a = m
 | 
			
		||||
                                .as_number()
 | 
			
		||||
                                .ok_or_else(|| {
 | 
			
		||||
                                    format!("array contained something which was not a number")
 | 
			
		||||
                                    "array contained something which was not a number".to_string()
 | 
			
		||||
                                })?
 | 
			
		||||
                                .into()
 | 
			
		||||
                        }
 | 
			
		||||
@@ -123,19 +123,19 @@ pub fn json_to_grids(json: JsonValue) -> Result<Vec<ExtendedGrid>, String> {
 | 
			
		||||
                    Ok(ArrayForm::Array2(arr))
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
                Err(format!("Inner object was not a string value, or an array"))
 | 
			
		||||
                Err("Inner object was not a string value, or an array".to_string())
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        let x = grid.remove("x");
 | 
			
		||||
        if x.is_empty() {
 | 
			
		||||
            return Err(format!("x was empty"));
 | 
			
		||||
            return Err("x was empty".to_string());
 | 
			
		||||
        }
 | 
			
		||||
        let x = to_array_form(x)?;
 | 
			
		||||
 | 
			
		||||
        let y = grid.remove("y");
 | 
			
		||||
        if y.is_empty() {
 | 
			
		||||
            return Err(format!("y was empty"));
 | 
			
		||||
            return Err("y was empty".to_string());
 | 
			
		||||
        }
 | 
			
		||||
        let y = to_array_form(y)?;
 | 
			
		||||
 | 
			
		||||
@@ -193,7 +193,7 @@ pub fn json_to_grids(json: JsonValue) -> Result<Vec<ExtendedGrid>, String> {
 | 
			
		||||
    match json {
 | 
			
		||||
        JsonValue::Array(a) => a
 | 
			
		||||
            .into_iter()
 | 
			
		||||
            .map(|g| json_to_grid(g))
 | 
			
		||||
            .map(json_to_grid)
 | 
			
		||||
            .collect::<Result<Vec<_>, _>>(),
 | 
			
		||||
        grid => Ok(vec![json_to_grid(grid)?]),
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user