Skip to content

Commit

Permalink
maint: add rustfmt and run it it pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ManonMarchand committed Oct 2, 2024
1 parent 9d86b44 commit 4e46dc5
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 36 deletions.
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@ repos:
hooks:
- id: ruff
fail_fast: true
- repo: local
hooks:
- id: cargofmt
name: cargofmt
entry: rustfmt
files: rs
language: system

1 change: 1 addition & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tab_spaces = 2
72 changes: 36 additions & 36 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,42 +844,42 @@ fn cdshealpix(_py: Python, m: &PyModule) -> PyResult<()> {
)
}

/// A box is defined by a center, two angles on the sides
/// and one rotation angle. Its sides follow great circles.
///
/// # Arguments
///
/// * ``depth``
/// * ``lon`` - center longitude, in degrees
/// * ``lat`` - center latitude in degrees
/// * ``a`` - size in degrees
/// * ``b`` - size in degrees
/// * ``pa`` -rotation angle in degrees
#[pyfn(m)]
fn box_search(
py: Python,
depth: u8,
lon: f64,
lat: f64,
a: f64,
b: f64,
pa: f64,
flat: bool,
) -> (Py<PyArray1<u64>>, Py<PyArray1<u8>>, Py<PyArray1<bool>>) {
let bmoc = healpix::nested::box_coverage(depth, lon, lat, a, b, pa);

let (ipix, depth, fully_covered) = if flat {
get_flat_cells(bmoc)
} else {
get_cells(bmoc)
};

(
ipix.into_pyarray(py).to_owned(),
depth.into_pyarray(py).to_owned(),
fully_covered.into_pyarray(py).to_owned(),
)
}
/// A box is defined by a center, two angles on the sides
/// and one rotation angle. Its sides follow great circles.
///
/// # Arguments
///
/// * ``depth``
/// * ``lon`` - center longitude, in degrees
/// * ``lat`` - center latitude in degrees
/// * ``a`` - size in degrees
/// * ``b`` - size in degrees
/// * ``pa`` -rotation angle in degrees
#[pyfn(m)]
fn box_search(
py: Python,
depth: u8,
lon: f64,
lat: f64,
a: f64,
b: f64,
pa: f64,
flat: bool,
) -> (Py<PyArray1<u64>>, Py<PyArray1<u8>>, Py<PyArray1<bool>>) {
let bmoc = healpix::nested::box_coverage(depth, lon, lat, a, b, pa);

let (ipix, depth, fully_covered) = if flat {
get_flat_cells(bmoc)
} else {
get_cells(bmoc)
};

(
ipix.into_pyarray(py).to_owned(),
depth.into_pyarray(py).to_owned(),
fully_covered.into_pyarray(py).to_owned(),
)
}

#[pyfn(m)]
unsafe fn external_neighbours(
Expand Down

0 comments on commit 4e46dc5

Please sign in to comment.