Optimisations

This commit is contained in:
Andras Schmelczer 2026-02-01 21:00:59 +00:00
parent 66c2a25457
commit 9179acd4cd
21 changed files with 653 additions and 139 deletions

View file

@ -4,8 +4,8 @@ mod grid_index_tests {
#[test]
fn query_bounds_fully_below_grid_returns_empty() {
let lat = vec![50.0, 50.5, 51.0];
let lon = vec![0.0, 0.5, 1.0];
let lat = vec![50.0_f32, 50.5, 51.0];
let lon = vec![0.0_f32, 0.5, 1.0];
let grid = GridIndex::build(&lat, &lon, 0.01);
let results = grid.query(10.0, -10.0, 20.0, -5.0);
@ -17,8 +17,8 @@ mod grid_index_tests {
#[test]
fn query_bounds_fully_above_grid_returns_empty() {
let lat = vec![50.0, 50.5, 51.0];
let lon = vec![0.0, 0.5, 1.0];
let lat = vec![50.0_f32, 50.5, 51.0];
let lon = vec![0.0_f32, 0.5, 1.0];
let grid = GridIndex::build(&lat, &lon, 0.01);
let results = grid.query(80.0, 50.0, 90.0, 60.0);
@ -30,8 +30,8 @@ mod grid_index_tests {
#[test]
fn query_inverted_bounds_returns_empty() {
let lat = vec![50.0, 50.5, 51.0];
let lon = vec![0.0, 0.5, 1.0];
let lat = vec![50.0_f32, 50.5, 51.0];
let lon = vec![0.0_f32, 0.5, 1.0];
let grid = GridIndex::build(&lat, &lon, 0.01);
// south > north
@ -44,8 +44,8 @@ mod grid_index_tests {
#[test]
fn for_each_bounds_fully_outside_yields_nothing() {
let lat = vec![50.0, 50.5, 51.0];
let lon = vec![0.0, 0.5, 1.0];
let lat = vec![50.0_f32, 50.5, 51.0];
let lon = vec![0.0_f32, 0.5, 1.0];
let grid = GridIndex::build(&lat, &lon, 0.01);
let mut count = 0;
@ -60,8 +60,8 @@ mod grid_index_tests {
fn query_with_large_cells_outside_returns_empty() {
// Previously, out-of-bounds queries with large cell sizes would
// scan cell (0,0) which could contain data. Now returns empty.
let lat = vec![50.0];
let lon = vec![0.0];
let lat = vec![50.0_f32];
let lon = vec![0.0_f32];
let grid = GridIndex::build(&lat, &lon, 1.0);
let results = grid.query(0.0, -50.0, 10.0, -40.0);
@ -73,8 +73,8 @@ mod grid_index_tests {
#[test]
fn query_within_bounds_returns_correct_results() {
let lat = vec![50.0, 50.5, 51.0];
let lon = vec![0.0, 0.5, 1.0];
let lat = vec![50.0_f32, 50.5, 51.0];
let lon = vec![0.0_f32, 0.5, 1.0];
let grid = GridIndex::build(&lat, &lon, 0.01);
let results = grid.query(49.9, -0.1, 51.1, 1.1);
@ -83,8 +83,8 @@ mod grid_index_tests {
#[test]
fn query_partial_bounds_returns_subset() {
let lat = vec![50.0, 51.0, 52.0];
let lon = vec![0.0, 0.0, 0.0];
let lat = vec![50.0_f32, 51.0, 52.0];
let lon = vec![0.0_f32, 0.0, 0.0];
let grid = GridIndex::build(&lat, &lon, 0.01);
let results = grid.query(49.9, -0.1, 50.1, 0.1);
@ -100,7 +100,7 @@ mod filter_tests {
#[test]
fn nan_rows_fail_numeric_filter_even_with_infinite_range() {
let feature_names = vec!["price".to_string()];
let feature_data = vec![f64::NAN];
let feature_data = vec![f32::NAN];
let enum_features: Vec<EnumFeatureData> = vec![];
let (numeric, enums) =