Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies and unit test #269

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ members = [

[workspace.dependencies]
serde = { version = "1.0.209", features = ["derive"] }
serde_json = { version = "1.0.127", features = ["preserve_order"] }
rayon = "1.7.0"
geo = { version = "0.28.0", features = ["use-serde"] }
geo-types = "0.7.12"
serde_json = { version = "1.0.133", features = ["preserve_order"] }
rayon = "1.10.0"
geo = { version = "0.29.3", features = ["use-serde"] }
geo-types = "0.7.14"
geojson = { version = "0.24.1" }
rstar = "0.12.0"
thiserror = "1.0.63"
flate2 = "1.0.33"
kdam = "0.5.2"
rstar = "0.12.2"
thiserror = "2.0.7"
flate2 = "1.0.35"
kdam = "0.6.2"
log = "0.4.22"
env_logger = "0.11.5"
csv = { version = "1.2.2" }
csv = { version = "1.3.1" }
itertools = { version = "0.13.0" }
chrono = "0.4.38"
regex = "1.10.6"
wkt = { version = "0.11.0", features = ["serde"] }
chrono = "0.4.39"
regex = "1.11.1"
wkt = { version = "0.12.0", features = ["serde"] }
wkb = "0.7.1"
config = "0.14"
ordered-float = { version = "4.2.2", features = ["serde"] }
allocative = "0.3.1"
indoc = "2"
config = "0.14.1"
ordered-float = { version = "4.5.0", features = ["serde"] }
allocative = "0.3.4"
indoc = "2.0.5"
derive_more = { version = "1.0.0", features = ["full"] }
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ mod test {
.join("test")
.join("Toyota_Camry.bin");

let model = InterpolationSpeedGradeModel::new(
let interp_model = InterpolationSpeedGradeModel::new(
&model_path,
ModelType::Smartcore,
"Toyota Camry".to_string(),
Expand All @@ -187,7 +187,46 @@ mod test {
)
.unwrap();

let (energy_rate, energy_rate_unit) = model
let underlying_model = load_prediction_model(
"Toyota Camry".to_string(),
&model_path,
ModelType::Smartcore,
SpeedUnit::MilesPerHour,
GradeUnit::Decimal,
EnergyRateUnit::GallonsGasolinePerMile,
None,
None,
None,
)
.unwrap();

// let's check to make sure the interpolation model is
// producing similar results to the underlying model

for speed in 0..100 {
for grade in -20..20 {
let (interp_energy_rate, _energy_rate_unit) = interp_model
.predict(
(Speed::new(speed as f64), SpeedUnit::MilesPerHour),
(Grade::new(grade as f64), GradeUnit::Percent),
)
.unwrap();
let (underlying_energy_rate, _energy_rate_unit) = underlying_model
.prediction_model
.predict(
(Speed::new(speed as f64), SpeedUnit::MilesPerHour),
(Grade::new(grade as f64), GradeUnit::Percent),
)
.unwrap();

// check if they're within 1% of each other
let diff = (interp_energy_rate.as_f64() - underlying_energy_rate.as_f64())
/ underlying_energy_rate.as_f64();
assert!(diff.abs() < 0.01);
}
}

let (energy_rate, energy_rate_unit) = interp_model
.predict(
(Speed::new(50.0), SpeedUnit::MilesPerHour),
(Grade::new(0.0), GradeUnit::Percent),
Expand Down
Loading