Skip to content

Commit

Permalink
Fix bug, release v0.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
fxpineau committed Nov 12, 2024
1 parent cfb8b62 commit 1ffb23a
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 5 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# `cdshealpix` Change Log

## 0.7.2

Released 2024-11-12

### Bug correction

* Wrong parameter (`cos(lon)` instead of `cos(lat)`)
in `h_to_h_and_shs` method leading to possibly miss
cells in cone/ring coverage in case of cones/ring
much smaller than requested HEALPix cells.


## 0.7.1

Released 2024-11-08
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.1"
version = "0.7.2"
authors = ["F.-X. Pineau <[email protected]>"]
edition = "2021"
rust-version = "1.81"
Expand Down
46 changes: 42 additions & 4 deletions src/nested/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2507,7 +2507,7 @@ impl Layer {
}
// Common variable
let cos_cone_lat = cone_lat.cos();
let shs_cone_radius = dbg!(to_squared_half_segment(cone_radius));
let shs_cone_radius = to_squared_half_segment(cone_radius);
// Special case of very large radius: test the 12 base cells
if !has_best_starting_depth(cone_radius) {
let distances = largest_center_to_vertex_distances_with_radius(
Expand Down Expand Up @@ -2982,8 +2982,9 @@ impl Layer {
),
);
let root_layer = get(depth_start);
let center_hash_at_depth_start = root_layer.hash(cone_lon, cone_lat);
let mut neigs: Vec<u64> = root_layer
.neighbours(root_layer.hash(cone_lon, cone_lat), true)
.neighbours(center_hash_at_depth_start, true)
.values_vec()
.iter()
.filter(|neigh| {
Expand Down Expand Up @@ -3287,8 +3288,9 @@ impl Layer {
),
);
let root_layer = get(depth_start);
let center_hash_at_depth_start = root_layer.hash(cone_lon, cone_lat);
let mut neigs: Vec<u64> = root_layer
.neighbours(root_layer.hash(cone_lon, cone_lat), true)
.neighbours(center_hash_at_depth_start, true)
.values_vec()
.iter()
.map(h_to_h_and_shs(cone_lon, cone_lat, cos_cone_lat, root_layer))
Expand Down Expand Up @@ -4399,7 +4401,7 @@ fn h_to_h_and_shs(
let (lon, lat) = layer.center(hash);
(
hash,
squared_half_segment(lon - cone_lon, lat - cone_lat, lon.cos(), cos_cone_lat),
squared_half_segment(lon - cone_lon, lat - cone_lat, lat.cos(), cos_cone_lat),
)
}
}
Expand Down Expand Up @@ -4827,6 +4829,42 @@ mod tests {
}
}

#[test]
fn testok_cone_approx_custom_bmoc_v2() {
let actual_res = cone_coverage_approx_custom(
6,
3,
8.401978_f64.to_radians(),
84.675171_f64.to_radians(),
0.0008_f64.to_radians(),
);
/*for cell in actual_res.flat_iter() {
println!("@@@@@ cell a: {:?}", cell);
}*/
let expected_res: [u64; 1] = [4075];
assert_eq!(actual_res.flat_iter().deep_size(), expected_res.len());
for (h1, h2) in actual_res.flat_iter().zip(expected_res.iter()) {
assert_eq!(h1, *h2);
}

println!("----------");

let actual_res = cone_coverage_approx_custom(
6,
3,
8.401978_f64.to_radians(),
84.675171_f64.to_radians(),
0.0004_f64.to_radians(),
);
/*for cell in actual_res.flat_iter() {
println!("@@@@@ cell a: {:?}", cell);
}*/
assert_eq!(actual_res.flat_iter().deep_size(), expected_res.len());
for (h1, h2) in actual_res.flat_iter().zip(expected_res.iter()) {
assert_eq!(h1, *h2);
}
}

#[test]
fn testok_cone_approx_custom_bmoc_dbg() {
let actual_res = cone_coverage_approx_custom(
Expand Down

0 comments on commit 1ffb23a

Please sign in to comment.