Skip to content

Commit

Permalink
fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Carow authored and Kyle Carow committed Dec 1, 2023
1 parent e60a5fa commit debb1a2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 78 deletions.
1 change: 1 addition & 0 deletions rust/fastsim-core/src/vehicle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,7 @@ impl RustVehicle {
input_kw_out_array: Default::default(),
fc_kw_out_array: Default::default(),
fc_eff_array: Default::default(),
max_regen_kwh: Default::default(),
mc_eff_array: Default::default(),
mc_perc_out_array: Default::default(),
mc_kw_out_array: Default::default(),
Expand Down
84 changes: 6 additions & 78 deletions rust/fastsim-core/src/vehicle_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,7 @@ pub struct OptionFE {
pub id: String,
}

impl SerdeAPI for OptionFE {
fn from_file(filename: &str) -> Result<Self, anyhow::Error> {
// check if the extension is csv, and if it is, then call Self::from_csv_file
let pathbuf = PathBuf::from(filename);
let file = File::open(filename)?;
let extension = pathbuf.extension().unwrap().to_str().unwrap();
match extension {
"yaml" => Ok(serde_yaml::from_reader(file)?),
"json" => Ok(serde_json::from_reader(file)?),
_ => Err(anyhow!("Unsupported file extension {}", extension)),
}
}
}
impl SerdeAPI for OptionFE {}

#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Clone)]
#[add_pyo3_api]
Expand Down Expand Up @@ -219,19 +207,7 @@ pub struct VehicleDataFE {
pub emissions_list: EmissionsListFE,
}

impl SerdeAPI for VehicleDataFE {
fn from_file(filename: &str) -> Result<Self, anyhow::Error> {
// check if the extension is csv, and if it is, then call Self::from_csv_file
let pathbuf = PathBuf::from(filename);
let file = File::open(filename)?;
let extension = pathbuf.extension().unwrap().to_str().unwrap();
match extension {
"yaml" => Ok(serde_yaml::from_reader(file)?),
"json" => Ok(serde_json::from_reader(file)?),
_ => Err(anyhow!("Unsupported file extension {}", extension)),
}
}
}
impl SerdeAPI for VehicleDataFE {}

#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Clone)]
#[serde(rename_all = "camelCase")]
Expand All @@ -242,19 +218,7 @@ pub struct EmissionsListFE {
pub emissions_info: Vec<EmissionsInfoFE>,
}

impl SerdeAPI for EmissionsListFE {
fn from_file(filename: &str) -> Result<Self, anyhow::Error> {
// check if the extension is csv, and if it is, then call Self::from_csv_file
let pathbuf = PathBuf::from(filename);
let file = File::open(filename)?;
let extension = pathbuf.extension().unwrap().to_str().unwrap();
match extension {
"yaml" => Ok(serde_yaml::from_reader(file)?),
"json" => Ok(serde_json::from_reader(file)?),
_ => Err(anyhow!("Unsupported file extension {}", extension)),
}
}
}
impl SerdeAPI for EmissionsListFE {}

#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Clone)]
#[serde(rename_all = "camelCase")]
Expand All @@ -273,19 +237,7 @@ pub struct EmissionsInfoFE {
pub std_text: String,
}

impl SerdeAPI for EmissionsInfoFE {
fn from_file(filename: &str) -> Result<Self, anyhow::Error> {
// check if the extension is csv, and if it is, then call Self::from_csv_file
let pathbuf = PathBuf::from(filename);
let file = File::open(filename)?;
let extension = pathbuf.extension().unwrap().to_str().unwrap();
match extension {
"yaml" => Ok(serde_yaml::from_reader(file)?),
"json" => Ok(serde_json::from_reader(file)?),
_ => Err(anyhow!("Unsupported file extension {}", extension)),
}
}
}
impl SerdeAPI for EmissionsInfoFE {}

#[derive(Default, PartialEq, Clone, Debug, Deserialize, Serialize)]
#[add_pyo3_api]
Expand Down Expand Up @@ -344,19 +296,7 @@ pub struct VehicleDataEPA {
pub c_lbf_per_mph2: f64,
}

impl SerdeAPI for VehicleDataEPA {
fn from_file(filename: &str) -> Result<Self, anyhow::Error> {
// check if the extension is csv, and if it is, then call Self::from_csv_file
let pathbuf = PathBuf::from(filename);
let file = File::open(filename)?;
let extension = pathbuf.extension().unwrap().to_str().unwrap();
match extension {
"yaml" => Ok(serde_yaml::from_reader(file)?),
"json" => Ok(serde_json::from_reader(file)?),
_ => Err(anyhow!("Unsupported file extension {}", extension)),
}
}
}
impl SerdeAPI for VehicleDataEPA {}

#[cfg_attr(feature = "pyo3", pyfunction)]
/// Gets options from fueleconomy.gov for the given vehicle year, make, and model
Expand Down Expand Up @@ -802,19 +742,7 @@ pub struct OtherVehicleInputs {
pub fc_max_kw: Option<f64>,
}

impl SerdeAPI for OtherVehicleInputs {
fn from_file(filename: &str) -> Result<Self, anyhow::Error> {
// check if the extension is csv, and if it is, then call Self::from_csv_file
let pathbuf = PathBuf::from(filename);
let file = File::open(filename)?;
let extension = pathbuf.extension().unwrap().to_str().unwrap();
match extension {
"yaml" => Ok(serde_yaml::from_reader(file)?),
"json" => Ok(serde_json::from_reader(file)?),
_ => Err(anyhow!("Unsupported file extension {}", extension)),
}
}
}
impl SerdeAPI for OtherVehicleInputs {}

#[cfg_attr(feature = "pyo3", pyfunction)]
/// Creates RustVehicle for the given vehicle using data from fueleconomy.gov and EPA databases
Expand Down

0 comments on commit debb1a2

Please sign in to comment.