diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7a266e7..b32c86a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ default_language_version: repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.3.4 + rev: v0.4.3 hooks: - id: ruff types: [python] @@ -12,7 +12,7 @@ repos: types: [python] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.9.0 + rev: v1.10.0 hooks: - id: mypy types: [python] @@ -24,6 +24,12 @@ repos: - id: fmt - id: cargo-check + - repo: https://github.com/doublify/pre-commit-rust + rev: v1.0 + hooks: + - id: fmt + - id: fmt + - repo: https://github.com/python-poetry/poetry rev: "1.8.0" hooks: diff --git a/src/lib.rs b/src/lib.rs index 637d457..17284f2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,9 +22,7 @@ impl From for PyErr { rust_fn::ReadError::ParseFloatError(e) => { PyErr::new::(format!("{}", e)) } - rust_fn::ReadError::MiscError(e) => { - PyErr::new::(format!("{}", e)) - } + rust_fn::ReadError::MiscError(e) => PyErr::new::(e), } } } diff --git a/src/rust_fn/mod.rs b/src/rust_fn/mod.rs index 1a26459..b86644d 100644 --- a/src/rust_fn/mod.rs +++ b/src/rust_fn/mod.rs @@ -36,8 +36,8 @@ pub fn read_layers(folder: &str) -> Result> { let mut glob_iterator = glob(glob_string.as_str())? .collect::, glob::GlobError>>()?; glob_iterator.par_sort_unstable_by(|a, b| { - let az = get_z(&a).expect("Filename parsing failed."); - let bz = get_z(&b).expect("Filename parsing failed."); + let az = get_z(a).expect("Filename parsing failed."); + let bz = get_z(b).expect("Filename parsing failed."); az.partial_cmp(&bz).expect("Filename sorting failed") }); let len: usize = glob_iterator.len(); @@ -168,7 +168,7 @@ pub fn read_file(filepath: PathBuf) -> Result<(Array2, f64, usize)> { Ok((array_read, z, z_len)) } -pub fn get_z(filepath: &PathBuf) -> Result { +pub fn get_z(filepath: &Path) -> Result { Ok(filepath .file_stem() .ok_or(ReadError::MiscError(format!( @@ -182,11 +182,11 @@ pub fn get_z(filepath: &PathBuf) -> Result { .parse::()?) } -pub fn correct_x(x: &mut f64) -> () { +pub fn correct_x(x: &mut f64) { *x = -((((*x + 16384.) * 0.009155273) - 87.) / 1.01); } -pub fn correct_y(y: &mut f64) -> () { +pub fn correct_y(y: &mut f64) { *y = (((*y + 16384.) * 0.009155273) - 91.) / 1.02; }