Skip to content

Commit

Permalink
chore: Remove Parameter::as_any_mut (#139)
Browse files Browse the repository at this point in the history
This method was only used by an experiment into the variable API.
That API was implemented in a different many. Therefore, remove
this unused API and the associated experimental (and dead) code.
  • Loading branch information
jetuk authored Mar 12, 2024
1 parent 0a9bbdb commit fb89773
Show file tree
Hide file tree
Showing 31 changed files with 1 addition and 158 deletions.
4 changes: 0 additions & 4 deletions pywr-core/src/parameters/aggregated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::parameters::{Parameter, ParameterMeta};
use crate::scenario::ScenarioIndex;
use crate::state::{ParameterState, State};
use crate::timestep::Timestep;
use std::any::Any;
use std::str::FromStr;

pub enum AggFunc {
Expand Down Expand Up @@ -48,9 +47,6 @@ impl AggregatedParameter {
}

impl Parameter<f64> for AggregatedParameter {
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
fn meta(&self) -> &ParameterMeta {
&self.meta
}
Expand Down
5 changes: 0 additions & 5 deletions pywr-core/src/parameters/aggregated_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::parameters::{IndexValue, Parameter, ParameterMeta};
use crate::scenario::ScenarioIndex;
use crate::state::{ParameterState, State};
use crate::timestep::Timestep;
use std::any::Any;
use std::str::FromStr;

pub enum AggIndexFunc {
Expand Down Expand Up @@ -51,10 +50,6 @@ impl AggregatedIndexParameter {
}

impl Parameter<usize> for AggregatedIndexParameter {
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}

fn meta(&self) -> &ParameterMeta {
&self.meta
}
Expand Down
7 changes: 0 additions & 7 deletions pywr-core/src/parameters/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::state::{ParameterState, State};
use crate::timestep::Timestep;
use crate::PywrError;
use ndarray::{Array1, Array2, Axis};
use std::any::Any;

pub struct Array1Parameter {
meta: ParameterMeta,
Expand All @@ -24,9 +23,6 @@ impl Array1Parameter {
}

impl Parameter<f64> for Array1Parameter {
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
fn meta(&self) -> &ParameterMeta {
&self.meta
}
Expand Down Expand Up @@ -67,9 +63,6 @@ impl Array2Parameter {
}

impl Parameter<f64> for Array2Parameter {
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
fn meta(&self) -> &ParameterMeta {
&self.meta
}
Expand Down
5 changes: 0 additions & 5 deletions pywr-core/src/parameters/asymmetric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::scenario::ScenarioIndex;
use crate::state::{ParameterState, State};
use crate::timestep::Timestep;
use crate::PywrError;
use std::any::Any;

pub struct AsymmetricSwitchIndexParameter {
meta: ParameterMeta,
Expand All @@ -23,10 +22,6 @@ impl AsymmetricSwitchIndexParameter {
}

impl Parameter<usize> for AsymmetricSwitchIndexParameter {
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}

fn meta(&self) -> &ParameterMeta {
&self.meta
}
Expand Down
5 changes: 0 additions & 5 deletions pywr-core/src/parameters/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use crate::scenario::ScenarioIndex;
use crate::state::{ParameterState, State};
use crate::timestep::Timestep;
use crate::PywrError;
use std::any::Any;

pub struct ConstantParameter {
meta: ParameterMeta,
Expand Down Expand Up @@ -38,10 +37,6 @@ impl ConstantParameter {
}

impl Parameter<f64> for ConstantParameter {
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}

fn meta(&self) -> &ParameterMeta {
&self.meta
}
Expand Down
5 changes: 0 additions & 5 deletions pywr-core/src/parameters/control_curves/apportion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::scenario::ScenarioIndex;
use crate::state::{MultiValue, ParameterState, State};
use crate::timestep::Timestep;
use crate::PywrError;
use std::any::Any;
use std::collections::HashMap;

/// A parameter which divides a apportions a metric to an upper and lower amount based
Expand Down Expand Up @@ -33,10 +32,6 @@ impl ApportionParameter {
}

impl Parameter<MultiValue> for ApportionParameter {
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}

fn meta(&self) -> &ParameterMeta {
&self.meta
}
Expand Down
5 changes: 0 additions & 5 deletions pywr-core/src/parameters/control_curves/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::scenario::ScenarioIndex;
use crate::state::{ParameterState, State};
use crate::timestep::Timestep;
use crate::PywrError;
use std::any::Any;

pub struct ControlCurveIndexParameter {
meta: ParameterMeta,
Expand All @@ -24,10 +23,6 @@ impl ControlCurveIndexParameter {
}

impl Parameter<usize> for ControlCurveIndexParameter {
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}

fn meta(&self) -> &ParameterMeta {
&self.meta
}
Expand Down
4 changes: 0 additions & 4 deletions pywr-core/src/parameters/control_curves/interpolated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::scenario::ScenarioIndex;
use crate::state::{ParameterState, State};
use crate::timestep::Timestep;
use crate::PywrError;
use std::any::Any;

pub struct ControlCurveInterpolatedParameter {
meta: ParameterMeta,
Expand All @@ -27,9 +26,6 @@ impl ControlCurveInterpolatedParameter {
}

impl Parameter<f64> for ControlCurveInterpolatedParameter {
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
fn meta(&self) -> &ParameterMeta {
&self.meta
}
Expand Down
4 changes: 0 additions & 4 deletions pywr-core/src/parameters/control_curves/piecewise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::scenario::ScenarioIndex;
use crate::state::{ParameterState, State};
use crate::timestep::Timestep;
use crate::PywrError;
use std::any::Any;

pub struct PiecewiseInterpolatedParameter {
meta: ParameterMeta,
Expand Down Expand Up @@ -38,9 +37,6 @@ impl PiecewiseInterpolatedParameter {
}

impl Parameter<f64> for PiecewiseInterpolatedParameter {
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
fn meta(&self) -> &ParameterMeta {
&self.meta
}
Expand Down
4 changes: 0 additions & 4 deletions pywr-core/src/parameters/control_curves/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::scenario::ScenarioIndex;
use crate::state::{ParameterState, State};
use crate::timestep::Timestep;
use crate::PywrError;
use std::any::Any;

pub struct ControlCurveParameter {
meta: ParameterMeta,
Expand All @@ -26,9 +25,6 @@ impl ControlCurveParameter {
}

impl Parameter<f64> for ControlCurveParameter {
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
fn meta(&self) -> &ParameterMeta {
&self.meta
}
Expand Down
5 changes: 0 additions & 5 deletions pywr-core/src/parameters/control_curves/volume_between.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::scenario::ScenarioIndex;
use crate::state::{ParameterState, State};
use crate::timestep::Timestep;
use crate::PywrError;
use std::any::Any;

/// A parameter that returns the volume that is the proportion between two control curves
pub struct VolumeBetweenControlCurvesParameter {
Expand All @@ -27,10 +26,6 @@ impl VolumeBetweenControlCurvesParameter {
}

impl Parameter<f64> for VolumeBetweenControlCurvesParameter {
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}

fn meta(&self) -> &ParameterMeta {
&self.meta
}
Expand Down
4 changes: 0 additions & 4 deletions pywr-core/src/parameters/delay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::scenario::ScenarioIndex;
use crate::state::{ParameterState, State};
use crate::timestep::Timestep;
use crate::PywrError;
use std::any::Any;
use std::collections::VecDeque;

pub struct DelayParameter {
Expand All @@ -27,9 +26,6 @@ impl DelayParameter {
}

impl Parameter<f64> for DelayParameter {
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
fn meta(&self) -> &ParameterMeta {
&self.meta
}
Expand Down
4 changes: 0 additions & 4 deletions pywr-core/src/parameters/discount_factor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::state::{ParameterState, State};
use crate::timestep::Timestep;
use crate::PywrError;
use chrono::Datelike;
use std::any::Any;

pub struct DiscountFactorParameter {
meta: ParameterMeta,
Expand All @@ -25,9 +24,6 @@ impl DiscountFactorParameter {
}

impl Parameter<f64> for DiscountFactorParameter {
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
fn meta(&self) -> &ParameterMeta {
&self.meta
}
Expand Down
4 changes: 0 additions & 4 deletions pywr-core/src/parameters/division.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::scenario::ScenarioIndex;
use crate::state::{ParameterState, State};
use crate::timestep::Timestep;
use crate::PywrError::InvalidMetricValue;
use std::any::Any;

pub struct DivisionParameter {
meta: ParameterMeta,
Expand All @@ -25,9 +24,6 @@ impl DivisionParameter {
}

impl Parameter<f64> for DivisionParameter {
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
fn meta(&self) -> &ParameterMeta {
&self.meta
}
Expand Down
4 changes: 0 additions & 4 deletions pywr-core/src/parameters/indexed_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::scenario::ScenarioIndex;
use crate::state::{ParameterState, State};
use crate::timestep::Timestep;
use crate::PywrError;
use std::any::Any;

pub struct IndexedArrayParameter {
meta: ParameterMeta,
Expand All @@ -24,9 +23,6 @@ impl IndexedArrayParameter {
}

impl Parameter<f64> for IndexedArrayParameter {
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
fn meta(&self) -> &ParameterMeta {
&self.meta
}
Expand Down
4 changes: 0 additions & 4 deletions pywr-core/src/parameters/interpolated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::scenario::ScenarioIndex;
use crate::state::{ParameterState, State};
use crate::timestep::Timestep;
use crate::PywrError;
use std::any::Any;

/// A parameter that interpolates a value to a function with given discrete data points.
pub struct InterpolatedParameter {
Expand All @@ -28,9 +27,6 @@ impl InterpolatedParameter {
}

impl Parameter<f64> for InterpolatedParameter {
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
fn meta(&self) -> &ParameterMeta {
&self.meta
}
Expand Down
5 changes: 0 additions & 5 deletions pywr-core/src/parameters/max.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ use crate::metric::Metric;
use crate::network::Network;
use crate::parameters::{Parameter, ParameterMeta};
use crate::scenario::ScenarioIndex;
use std::any::Any;

use crate::state::{ParameterState, State};
use crate::timestep::Timestep;
use crate::PywrError;
Expand All @@ -25,9 +23,6 @@ impl MaxParameter {
}

impl Parameter<f64> for MaxParameter {
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
fn meta(&self) -> &ParameterMeta {
&self.meta
}
Expand Down
5 changes: 0 additions & 5 deletions pywr-core/src/parameters/min.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ use crate::metric::Metric;
use crate::network::Network;
use crate::parameters::{Parameter, ParameterMeta};
use crate::scenario::ScenarioIndex;
use std::any::Any;

use crate::state::{ParameterState, State};
use crate::timestep::Timestep;
use crate::PywrError;
Expand All @@ -25,9 +23,6 @@ impl MinParameter {
}

impl Parameter<f64> for MinParameter {
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
fn meta(&self) -> &ParameterMeta {
&self.meta
}
Expand Down
1 change: 0 additions & 1 deletion pywr-core/src/parameters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ pub fn downcast_variable_config_ref<T: 'static>(variable_config: &dyn VariableCo
///
/// The trait is generic over the type of the value produced.
pub trait Parameter<T>: Send + Sync {
fn as_any_mut(&mut self) -> &mut dyn Any;
fn meta(&self) -> &ParameterMeta;
fn name(&self) -> &str {
self.meta().name.as_str()
Expand Down
4 changes: 0 additions & 4 deletions pywr-core/src/parameters/negative.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::scenario::ScenarioIndex;
use crate::state::{ParameterState, State};
use crate::timestep::Timestep;
use crate::PywrError;
use std::any::Any;

pub struct NegativeParameter {
meta: ParameterMeta,
Expand All @@ -22,9 +21,6 @@ impl NegativeParameter {
}

impl Parameter<f64> for NegativeParameter {
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
fn meta(&self) -> &ParameterMeta {
&self.meta
}
Expand Down
5 changes: 0 additions & 5 deletions pywr-core/src/parameters/offset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ use crate::parameters::{
Parameter, ParameterMeta, VariableConfig, VariableParameter,
};
use crate::scenario::ScenarioIndex;
use std::any::Any;

use crate::state::{ParameterState, State};
use crate::timestep::Timestep;
use crate::PywrError;
Expand Down Expand Up @@ -42,9 +40,6 @@ impl OffsetParameter {
}

impl Parameter<f64> for OffsetParameter {
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
fn meta(&self) -> &ParameterMeta {
&self.meta
}
Expand Down
Loading

0 comments on commit fb89773

Please sign in to comment.