mirror of
https://github.com/Cian-H/read_aconity_layers.git
synced 2025-12-23 10:41:58 +00:00
Linted, formatted, and added hooks
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -22,9 +22,7 @@ impl From<rust_fn::ReadError> for PyErr {
|
||||
rust_fn::ReadError::ParseFloatError(e) => {
|
||||
PyErr::new::<exceptions::PyRuntimeError, _>(format!("{}", e))
|
||||
}
|
||||
rust_fn::ReadError::MiscError(e) => {
|
||||
PyErr::new::<exceptions::PyRuntimeError, _>(format!("{}", e))
|
||||
}
|
||||
rust_fn::ReadError::MiscError(e) => PyErr::new::<exceptions::PyRuntimeError, _>(e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ pub fn read_layers(folder: &str) -> Result<Array2<f64>> {
|
||||
let mut glob_iterator = glob(glob_string.as_str())?
|
||||
.collect::<std::result::Result<Vec<PathBuf>, 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>, f64, usize)> {
|
||||
Ok((array_read, z, z_len))
|
||||
}
|
||||
|
||||
pub fn get_z(filepath: &PathBuf) -> Result<f64> {
|
||||
pub fn get_z(filepath: &Path) -> Result<f64> {
|
||||
Ok(filepath
|
||||
.file_stem()
|
||||
.ok_or(ReadError::MiscError(format!(
|
||||
@@ -182,11 +182,11 @@ pub fn get_z(filepath: &PathBuf) -> Result<f64> {
|
||||
.parse::<f64>()?)
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user