Skip to content

Commit

Permalink
correct a number of compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
shieldo committed Apr 9, 2024
1 parent 4e13fc0 commit a618519
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 34 deletions.
2 changes: 0 additions & 2 deletions src/core/controls/time_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ pub enum Control {
}

// macro so accessing individual controls through the enum isn't so repetitive
#[macro_use]
macro_rules! per_control {
($val:expr, $pattern:pat => { $res:expr }) => {
match $val {
Expand Down Expand Up @@ -296,7 +295,6 @@ impl ControlBehaviour for SetpointTimeControl {
mod test {
use super::*;
use crate::simulation_time::{SimulationTime, SimulationTimeIterator};
use itertools::Itertools;
use rstest::*;

const ON_OFF_SCHEDULE: [bool; 8] = [true, false, true, true, false, true, false, false];
Expand Down
17 changes: 6 additions & 11 deletions src/core/energy_supply/energy_supply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl EnergySupplies {
energy_supply_type: EnergySupplyType,
timesteps: usize,
) -> Arc<Mutex<EnergySupply>> {
let mut energy_supply = match energy_supply_type {
let energy_supply = match energy_supply_type {
EnergySupplyType::Electricity => &mut self.mains_electricity,
EnergySupplyType::MainsGas => &mut self.mains_gas,
EnergySupplyType::UnmetDemand => return self.unmet_demand.clone(),
Expand All @@ -56,16 +56,11 @@ impl EnergySupplies {
};
match energy_supply {
Some(supply) => supply.clone(),
None => {
let supply = Arc::new(Mutex::new(EnergySupply::new(
energy_supply_type,
timesteps,
None,
)));
energy_supply = &mut Some(supply.clone());

supply
}
None => Arc::new(Mutex::new(EnergySupply::new(
energy_supply_type,
timesteps,
None,
))),
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/heating_systems/boiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ mod tests {

#[rstest]
pub fn should_provide_correct_energy_output(
mut boiler: (Boiler, Arc<Mutex<EnergySupply>>),
boiler: (Boiler, Arc<Mutex<EnergySupply>>),
simulation_time: SimulationTime,
boiler_energy_output_required: [f64; 2],
temp_return_feed: [f64; 2],
Expand Down Expand Up @@ -1305,7 +1305,7 @@ mod tests {

#[fixture]
pub fn service_space_boiler(
mut boiler_for_service_space: Boiler,
boiler_for_service_space: Boiler,
control_for_service_space: Control,
) -> BoilerServiceSpace {
BoilerServiceSpace::new(
Expand Down
6 changes: 3 additions & 3 deletions src/core/heating_systems/storage_tank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1243,12 +1243,12 @@ impl SolarThermalSystem {
#[cfg(test)]
mod tests {
use super::*;
use crate::core::controls::time_control::{per_control, OnOffTimeControl};
use crate::core::controls::time_control::OnOffTimeControl;
use crate::core::energy_supply::energy_supply::EnergySupply;
use crate::core::material_properties::WATER;
use crate::core::water_heat_demand::cold_water_source::ColdWaterSource;
use crate::corpus::HeatSource;
use crate::input::{EnergySupplyType, HeatSourceControl, HeatSourceControlType};
use crate::input::EnergySupplyType;
use crate::simulation_time::SimulationTime;
use rstest::*;

Expand Down Expand Up @@ -1344,7 +1344,7 @@ mod tests {

#[rstest]
pub fn should_calc_demand_hot_water_for_storage_tank(
mut storage_tank: (StorageTank, Arc<Mutex<EnergySupply>>),
storage_tank: (StorageTank, Arc<Mutex<EnergySupply>>),
simulation_time_for_storage_tank: SimulationTime,
) {
let (mut storage_tank, energy_supply) = storage_tank;
Expand Down
2 changes: 1 addition & 1 deletion src/core/space_heat_demand/ventilation_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ mod test {

#[rstest]
pub fn should_have_correct_fan_gains(
mut mvhr: (MechanicalVentilationHeatRecovery, Arc<Mutex<EnergySupply>>),
mvhr: (MechanicalVentilationHeatRecovery, Arc<Mutex<EnergySupply>>),
simulation_time_iterator: SimulationTimeIterator,
) {
let (mut mvhr, energy_supply) = mvhr;
Expand Down
3 changes: 1 addition & 2 deletions src/core/space_heat_demand/zone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1368,8 +1368,7 @@ mod test {
use crate::core::units::DAYS_IN_MONTH;
use crate::external_conditions::DaylightSavingsConfig;
use crate::input::{
InfiltrationBuildType, InfiltrationShelterType, InfiltrationTestType,
MassDistributionClass, ZoneInput,
InfiltrationBuildType, InfiltrationShelterType, InfiltrationTestType, MassDistributionClass,
};
use crate::simulation_time::{SimulationTime, HOURS_IN_DAY};
use indexmap::IndexMap;
Expand Down
5 changes: 3 additions & 2 deletions src/core/water_heat_demand/shower.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::core::energy_supply::energy_supply::{EnergySupply, EnergySupplyConnection};
use crate::core::energy_supply::energy_supply::EnergySupplyConnection;
use crate::core::heating_systems::wwhrs::Wwhrs;
use crate::core::material_properties::WATER;
use crate::core::units::MINUTES_PER_HOUR;
Expand Down Expand Up @@ -161,6 +161,7 @@ impl InstantElectricShower {
#[cfg(test)]
mod tests {
use super::*;
use crate::core::energy_supply::energy_supply::EnergySupply;
use crate::input::EnergySupplyType;
use crate::simulation_time::SimulationTime;
use parking_lot::Mutex;
Expand Down Expand Up @@ -189,7 +190,7 @@ mod tests {
let cold_water_temps = [2.0, 3.0, 4.0];
let cold_water_source =
ColdWaterSource::new(cold_water_temps.into(), &simulation_time, 1.0);
let mut energy_supply = Arc::new(Mutex::new(EnergySupply::new(
let energy_supply = Arc::new(Mutex::new(EnergySupply::new(
EnergySupplyType::Electricity,
simulation_time.total_steps(),
None,
Expand Down
4 changes: 2 additions & 2 deletions src/corpus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -905,8 +905,8 @@ impl Corpus {
("internal_boundary".try_into().unwrap(), Default::default()),
("external_boundary".try_into().unwrap(), Default::default()),
]);
let mut heat_source_wet_results_dict = Default::default();
let mut heat_source_wet_results_annual_dict = Default::default();
let heat_source_wet_results_dict = Default::default();
let heat_source_wet_results_annual_dict = Default::default();

for z_name in self.zones.keys() {
let z_name = z_name.as_str().try_into().unwrap();
Expand Down
18 changes: 9 additions & 9 deletions src/external_conditions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1936,7 +1936,7 @@ mod test {
air_temps: Vec<f64>,
simulation_time_iterator: SimulationTimeIterator,
) {
let mut external_conditions = external_conditions.clone();
let external_conditions = external_conditions.clone();
for (i, simtime_step) in simulation_time_iterator.enumerate() {
assert_eq!(
external_conditions.air_temp(&simtime_step),
Expand All @@ -1956,8 +1956,8 @@ mod test {
fn should_have_correct_air_temp_annual(external_conditions: ExternalConditions) {
let precision = 1e6;
assert_eq!(
round_by_precision(external_conditions.air_temp_annual().unwrap(), 1e6),
round_by_precision(10.1801369863014, 1e6)
round_by_precision(external_conditions.air_temp_annual().unwrap(), precision),
round_by_precision(10.1801369863014, precision)
);
}

Expand All @@ -1969,7 +1969,7 @@ mod test {
let expected_monthly_air_temps: [f64; 12] = [
6.75, 7.75, 8.75, 9.75, 10.75, 11.75, 12.75, 12.75, 11.75, 10.75, 9.75, 8.75,
];
let mut external_conditions = external_conditions.clone();
let external_conditions = external_conditions.clone();
for (i, simtime_step) in simulation_time_iterator.enumerate() {
let month_idx = simtime_step.current_month().unwrap() as usize;
assert_eq!(
Expand Down Expand Up @@ -2008,8 +2008,8 @@ mod test {
diffuse_horizontal_radiation: [f64; 8],
simulation_time_iterator: SimulationTimeIterator,
) {
let mut external_conditions = external_conditions.clone();
for (i, simtime_step) in simulation_time_iterator.enumerate() {
let external_conditions = external_conditions.clone();
for (i, _simtime_step) in simulation_time_iterator.enumerate() {
assert_eq!(
external_conditions.diffuse_horizontal_radiation(i),
diffuse_horizontal_radiation[i]
Expand All @@ -2023,8 +2023,8 @@ mod test {
direct_beam_radiation: [f64; 8],
simulation_time_iterator: SimulationTimeIterator,
) {
let mut external_conditions = external_conditions.clone();
for (i, simtime_step) in simulation_time_iterator.enumerate() {
let external_conditions = external_conditions.clone();
for (i, _simtime_step) in simulation_time_iterator.enumerate() {
assert_eq!(
external_conditions.direct_beam_radiation(i),
direct_beam_radiation[i]
Expand All @@ -2038,7 +2038,7 @@ mod test {
solar_reflectivity_of_ground: [f64; 8760],
simulation_time_iterator: SimulationTimeIterator,
) {
let mut external_conditions = external_conditions.clone();
let external_conditions = external_conditions.clone();
for (i, simtime_step) in simulation_time_iterator.enumerate() {
assert_eq!(
external_conditions.solar_reflectivity_of_ground(&simtime_step),
Expand Down

0 comments on commit a618519

Please sign in to comment.