Skip to content

Commit

Permalink
Fix minor bug in zone_coverage, v0.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
fxpineau committed Nov 8, 2024
1 parent 25556a5 commit cfb8b62
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# `cdshealpix` Change Log

## 0.7.1

Released 2024-11-08

### Changed

* Skymap/MOM modified to take into account @hombit feedbacks

### Bug correction

* Upper left corner of `zone_coverage` no more included in the output MOC


## 0.7.0

Released 2024-10-16
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cdshealpix"
version = "0.7.0"
version = "0.7.1"
authors = ["F.-X. Pineau <[email protected]>"]
edition = "2021"
rust-version = "1.81"
Expand Down
29 changes: 28 additions & 1 deletion src/nested/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use self::{
pub mod bmoc;
pub mod gpu;
pub mod map;
// pub mod sort;
pub mod zordercurve;

// We use an array here since operations on f64 are not yet stable for `const fn` :o/
Expand Down Expand Up @@ -2447,7 +2448,7 @@ impl Layer {
} else if n_in > 0
|| zone_vertices_hashs[0] >> shift == hash
|| zone_vertices_hashs[1] >> shift == hash
|| zone_vertices_hashs[2] >> shift == hash
// || zone_vertices_hashs[2] >> shift == hash // Correspond to lon_max, lat_max, which should be excluded
|| zone_vertices_hashs[3] >> shift == hash
|| zone.crossed_vertically(l_n, b_n, b_s) // we may have false positive in the polar caps around n*PI/2
|| zone.crossed_vertically(l_s, b_n, b_s) // we may have false positive in the polar caps around n*PI/2
Expand Down Expand Up @@ -6718,6 +6719,32 @@ mod tests {
}
}

#[test]
fn testok_zone_5() {
let depth = 3;
let (lon_min, lat_min, lon_max, lat_max) = (
180_f64.to_radians(),
30_f64.to_radians(),
360.0_f64.to_radians(),
50_f64.to_radians(),
);
let expected_res_exact: [u64; 94] = [
85, 87, 135, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
155, 156, 157, 158, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173,
174, 176, 177, 178, 199, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215,
216, 217, 218, 219, 220, 221, 222, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234,
235, 236, 237, 238, 240, 241, 242, 315, 318, 319, 439, 444, 445, 446, 447, 503, 507, 508,
509, 510, 511,
];
let actual_res_exact = zone_coverage(depth, lon_min, lat_min, lon_max, lat_max);
// to_aladin_moc(&actual_res_exact);
assert!(actual_res_exact.deep_size() > 0);
assert_eq!(expected_res_exact.len(), actual_res_exact.deep_size());
for (h1, h2) in actual_res_exact.flat_iter().zip(expected_res_exact.iter()) {
assert_eq!(h1, *h2);
}
}

fn to_radians(lonlats: &mut [(f64, f64)]) {
for (lon, lat) in lonlats.iter_mut() {
*lon = lon.to_radians();
Expand Down

0 comments on commit cfb8b62

Please sign in to comment.