diff --git a/src/data/builder.rs b/src/data/builder.rs index ed0a57a8..07701b86 100644 --- a/src/data/builder.rs +++ b/src/data/builder.rs @@ -111,7 +111,7 @@ impl SubjectBuilder { /// Prefer stable route names such as `"depot"` or `"iv"` when the model /// declares named routes. pub fn bolus(self, time: f64, amount: f64, input: impl ToString) -> Self { - let bolus = Bolus::new(time, amount, input, self.current_occasion.index()); + let bolus = Bolus::new(time, amount, input); let event = Event::Bolus(bolus); self.event(event) } @@ -125,7 +125,7 @@ impl SubjectBuilder { /// * `input` - Public input label receiving the dose /// * `duration` - Duration of the infusion in time units pub fn infusion(self, time: f64, amount: f64, input: impl ToString, duration: f64) -> Self { - let infusion = Infusion::new(time, amount, input, duration, self.current_occasion.index()); + let infusion = Infusion::new(time, amount, input, duration); let event = Event::Infusion(infusion); self.event(event) } @@ -138,14 +138,7 @@ impl SubjectBuilder { /// * `value` - Observed value (e.g., drug concentration) /// * `outeq` - Public output label for this observation pub fn observation(self, time: f64, value: f64, outeq: impl ToString) -> Self { - let observation = Observation::new( - time, - Some(value), - outeq, - None, - self.current_occasion.index(), - Censor::None, - ); + let observation = Observation::new(time, Some(value), outeq, None, Censor::None); let event = Event::Observation(observation); self.event(event) } @@ -165,14 +158,7 @@ impl SubjectBuilder { outeq: impl ToString, censoring: Censor, ) -> Self { - let observation = Observation::new( - time, - Some(value), - outeq, - None, - self.current_occasion.index(), - censoring, - ); + let observation = Observation::new(time, Some(value), outeq, None, censoring); let event = Event::Observation(observation); self.event(event) } @@ -187,14 +173,7 @@ impl SubjectBuilder { /// Use this when you want a prediction at a time point but do not have an /// observed value. pub fn missing_observation(self, time: f64, outeq: impl ToString) -> Self { - let observation = Observation::new( - time, - None, - outeq, - None, - self.current_occasion.index(), - Censor::None, - ); + let observation = Observation::new(time, None, outeq, None, Censor::None); let event = Event::Observation(observation); self.event(event) } @@ -216,14 +195,7 @@ impl SubjectBuilder { errorpoly: ErrorPoly, censored: Censor, ) -> Self { - let observation = Observation::new( - time, - Some(value), - outeq, - Some(errorpoly), - self.current_occasion.index(), - censored, - ); + let observation = Observation::new(time, Some(value), outeq, Some(errorpoly), censored); let event = Event::Observation(observation); self.event(event) } diff --git a/src/data/error_model.rs b/src/data/error_model.rs index 1fffca20..db9625f1 100644 --- a/src/data/error_model.rs +++ b/src/data/error_model.rs @@ -1184,7 +1184,7 @@ mod tests { #[test] fn test_additive_error_model() { - let observation = Observation::new(0.0, Some(20.0), 0, None, 0, Censor::None); + let observation = Observation::new(0.0, Some(20.0), 0, None, Censor::None); let prediction = observation.to_prediction(10.0, vec![]); let model = AssayErrorModel::additive(ErrorPoly::new(1.0, 0.0, 0.0, 0.0), 5.0); assert_eq!(model.sigma(&prediction).unwrap(), (26.0_f64).sqrt()); @@ -1192,7 +1192,7 @@ mod tests { #[test] fn test_proportional_error_model() { - let observation = Observation::new(0.0, Some(20.0), 0, None, 0, Censor::None); + let observation = Observation::new(0.0, Some(20.0), 0, None, Censor::None); let prediction = observation.to_prediction(10.0, vec![]); let model = AssayErrorModel::proportional(ErrorPoly::new(1.0, 0.0, 0.0, 0.0), 2.0); assert_eq!(model.sigma(&prediction).unwrap(), 2.0); @@ -1353,7 +1353,7 @@ mod tests { .add("cp", model) .unwrap(); - let observation = Observation::new(0.0, Some(20.0), 0, None, 0, Censor::None); + let observation = Observation::new(0.0, Some(20.0), 0, None, Censor::None); let prediction = observation.to_prediction(10.0, vec![]); assert_eq!(models.sigma(&prediction).unwrap(), (26.0_f64).sqrt()); @@ -1479,7 +1479,7 @@ mod tests { let model = AssayErrorModel::additive(ErrorPoly::new(1.0, 0.0, 0.0, 0.0), 5.0); let models = AssayErrorModels::empty().add(0, model).unwrap(); - let observation = Observation::new(0.0, Some(20.0), 0, None, 0, Censor::None); + let observation = Observation::new(0.0, Some(20.0), 0, None, Censor::None); let prediction = observation.to_prediction(10.0, vec![]); // Non-parametric: sigma from observation @@ -1492,7 +1492,7 @@ mod tests { let model = AssayErrorModel::additive(ErrorPoly::new(1.0, 0.0, 0.0, 0.0), 5.0); let models = AssayErrorModels::empty().add(0, model).unwrap(); - let observation = Observation::new(0.0, Some(20.0), 1, None, 0, Censor::None); // outeq=1 not in models + let observation = Observation::new(0.0, Some(20.0), 1, None, Censor::None); // outeq=1 not in models let prediction = observation.to_prediction(10.0, vec![]); let result = models.sigma(&prediction); @@ -1508,7 +1508,7 @@ mod tests { let model = AssayErrorModel::additive(ErrorPoly::new(1.0, 0.0, 0.0, 0.0), 5.0); let models = AssayErrorModels::empty().add(0, model).unwrap(); - let observation = Observation::new(0.0, Some(20.0), 0, None, 0, Censor::None); + let observation = Observation::new(0.0, Some(20.0), 0, None, Censor::None); let prediction = observation.to_prediction(10.0, vec![]); let variance = models.variance(&prediction).unwrap(); @@ -1521,7 +1521,7 @@ mod tests { let model = AssayErrorModel::additive(ErrorPoly::new(1.0, 0.0, 0.0, 0.0), 5.0); let models = AssayErrorModels::empty().add(0, model).unwrap(); - let observation = Observation::new(0.0, Some(20.0), 1, None, 0, Censor::None); // outeq=1 not in models + let observation = Observation::new(0.0, Some(20.0), 1, None, Censor::None); // outeq=1 not in models let prediction = observation.to_prediction(10.0, vec![]); let result = models.variance(&prediction); @@ -1662,13 +1662,13 @@ mod tests { .unwrap(); // Test with outeq=0 (additive model) - let obs1 = Observation::new(0.0, Some(20.0), 0, None, 0, Censor::None); + let obs1 = Observation::new(0.0, Some(20.0), 0, None, Censor::None); let pred1 = obs1.to_prediction(10.0, vec![]); let sigma1 = models.sigma(&pred1).unwrap(); assert_eq!(sigma1, (26.0_f64).sqrt()); // additive: sqrt(alpha^2 + lambda^2) = sqrt(1^2 + 5^2) = sqrt(26) // Test with outeq=1 (proportional model) - let obs2 = Observation::new(0.0, Some(20.0), 1, None, 0, Censor::None); + let obs2 = Observation::new(0.0, Some(20.0), 1, None, Censor::None); let pred2 = obs2.to_prediction(10.0, vec![]); let sigma2 = models.sigma(&pred2).unwrap(); assert_eq!(sigma2, 2.0); // proportional: gamma * alpha = 2 * 1 = 2 @@ -1810,7 +1810,7 @@ mod tests { #[test] fn test_fixed_parameters_in_calculations() { // Test that fixed and variable parameters produce the same calculation results - let observation = Observation::new(0.0, Some(20.0), 0, None, 0, Censor::None); + let observation = Observation::new(0.0, Some(20.0), 0, None, Censor::None); let prediction = observation.to_prediction(10.0, vec![]); let model_variable = AssayErrorModel::additive(ErrorPoly::new(1.0, 0.0, 0.0, 0.0), 5.0); diff --git a/src/data/event.rs b/src/data/event.rs index 2b14c9f4..b9897b56 100644 --- a/src/data/event.rs +++ b/src/data/event.rs @@ -15,10 +15,6 @@ use crate::prelude::simulator::Prediction; use serde::{Deserialize, Serialize}; use std::fmt; -// ============================================================================ -// Shared Analysis Types -// ============================================================================ - /// Administration route classification used by downstream analyses. /// /// [`Route`] is a coarse route category, not the original public input label. @@ -94,6 +90,14 @@ pub enum BLQRule { }, } +/// Flag to indicate whether a dose is fixed or estimatable +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default, Copy)] +pub enum DoseEstimation { + #[default] + Fixed, + Estimable, +} + /// One scheduled item in a subject record. /// /// Events are the low-level representation for doses and observations: @@ -311,39 +315,6 @@ impl Event { Event::Observation(observation) => observation.time += dt, } } - - /// Get the occasion index for this event - pub fn occasion(&self) -> usize { - match self { - Event::Bolus(bolus) => bolus.occasion, - Event::Infusion(infusion) => infusion.occasion, - Event::Observation(observation) => observation.occasion, - } - } - - /// Get a mutable reference to the occasion index - pub fn mut_occasion(&mut self) -> &mut usize { - match self { - Event::Bolus(bolus) => bolus.mut_occasion(), - Event::Infusion(infusion) => infusion.mut_occasion(), - Event::Observation(observation) => observation.mut_occasion(), - } - } - - /// Set the occasion index for this event - pub fn set_occasion(&mut self, occasion: usize) { - match self { - Event::Bolus(_) => { - *self.mut_occasion() = occasion; - } - Event::Infusion(_) => { - *self.mut_occasion() = occasion; - } - Event::Observation(_) => { - *self.mut_occasion() = occasion; - } - } - } } /// Instantaneous dose input. @@ -355,7 +326,7 @@ pub struct Bolus { time: f64, amount: f64, input: InputLabel, - occasion: usize, + mode: DoseEstimation, } impl Bolus { /// Create a new bolus event @@ -365,15 +336,30 @@ impl Bolus { /// * `time` - Time of the bolus dose /// * `amount` - Amount of drug administered /// * `input` - The route label receiving the dose - pub fn new(time: f64, amount: f64, input: impl ToString, occasion: usize) -> Self { + pub fn new(time: f64, amount: f64, input: impl ToString) -> Self { Bolus { time, amount, input: InputLabel::new(input), - occasion, + mode: DoseEstimation::default(), } } + /// Get the dose estimation mode for this bolus + pub fn mode(&self) -> DoseEstimation { + self.mode + } + + /// Set the dose estimation mode for this bolus + pub fn set_mode(&mut self, mode: DoseEstimation) { + self.mode = mode; + } + + /// Get a mutable reference to the dose estimation mode for this bolus + pub fn mut_mode(&mut self) -> &mut DoseEstimation { + &mut self.mode + } + /// Get the amount of drug in the bolus pub fn amount(&self) -> f64 { self.amount @@ -425,16 +411,6 @@ impl Bolus { pub fn mut_time(&mut self) -> &mut f64 { &mut self.time } - - /// Get the occasion index for this bolus - pub fn occasion(&self) -> usize { - self.occasion - } - - /// Get a mutable reference to the occasion index - pub fn mut_occasion(&mut self) -> &mut usize { - &mut self.occasion - } } /// Continuous dose input over a duration. @@ -447,7 +423,7 @@ pub struct Infusion { amount: f64, input: InputLabel, duration: f64, - occasion: usize, + mode: DoseEstimation, } impl Infusion { /// Create a new infusion event @@ -458,22 +434,49 @@ impl Infusion { /// * `amount` - Total amount of drug to be administered /// * `input` - The route label receiving the dose /// * `duration` - Duration of the infusion in time units - pub fn new( - time: f64, - amount: f64, - input: impl ToString, - duration: f64, - occasion: usize, - ) -> Self { + pub fn new(time: f64, amount: f64, input: impl ToString, duration: f64) -> Self { + Infusion { + time, + amount, + input: InputLabel::new(input), + duration, + mode: DoseEstimation::Fixed, + } + } + + /// Creat a new, estimable infusion event + /// + /// # Arguments + /// + /// * `time` - Start time of the infusion + /// * `amount` - Total amount of drug to be administered + /// * `input` - The route label receiving the dose + /// * `duration` - Duration of the infusion in time units + pub fn new_estimable(time: f64, amount: f64, input: impl ToString, duration: f64) -> Self { Infusion { time, amount, input: InputLabel::new(input), duration, - occasion, + mode: DoseEstimation::Estimable, } } + /// Get the mode of dose estimation for this infusion + pub fn mode(&self) -> DoseEstimation { + self.mode + } + + /// Get a mutable reference to the mode of dose estimation for this infusion + pub fn mut_mode(&mut self) -> &mut DoseEstimation { + &mut self.mode + } + + /// Set the mode of dose estimation for this infusion + pub fn set_mode(&mut self, mode: DoseEstimation) { + self.mode = mode; + } + /// Get the total amount of drug provided over the infusion pub fn amount(&self) -> f64 { self.amount @@ -542,16 +545,6 @@ impl Infusion { pub fn mut_duration(&mut self) -> &mut f64 { &mut self.duration } - - /// Get the occasion index for this infusion - pub fn occasion(&self) -> usize { - self.occasion - } - - /// Get a mutable reference to the occasion index - pub fn mut_occasion(&mut self) -> &mut usize { - &mut self.occasion - } } #[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)] @@ -570,14 +563,13 @@ pub enum Censor { /// /// An [`Observation`] can carry a measured value or `None` for a prediction-only /// time point. Observations also carry the public output label, optional assay -/// error polynomial, occasion index, and censoring state. +/// error polynomial, and censoring state. #[derive(Serialize, Debug, Clone, Deserialize)] pub struct Observation { time: f64, value: Option, outeq: OutputLabel, errorpoly: Option, - occasion: usize, censoring: Censor, } impl Observation { @@ -589,14 +581,12 @@ impl Observation { /// * `value` - Observed value (e.g., drug concentration) /// * `outeq` - Output label corresponding to this observation /// * `errorpoly` - Optional error polynomial coefficients (c0, c1, c2, c3) - /// * `occasion` - Occasion index /// * `censoring` - Censoring type for this observation pub(crate) fn new( time: f64, value: Option, outeq: impl ToString, errorpoly: Option, - occasion: usize, censoring: Censor, ) -> Self { Observation { @@ -604,7 +594,6 @@ impl Observation { value, outeq: OutputLabel::new(outeq), errorpoly, - occasion, censoring, } } @@ -680,16 +669,6 @@ impl Observation { &mut self.errorpoly } - /// Get the occasion index for this observation - pub fn occasion(&self) -> usize { - self.occasion - } - - /// Get a mutable reference to the occasion index - pub fn mut_occasion(&mut self) -> &mut usize { - &mut self.occasion - } - /// Create a [`Prediction`] from this observation. /// /// This is a low-level helper for code paths that already operate on a @@ -705,7 +684,6 @@ impl Observation { .expect("prediction requires a resolved or numeric output label"), errorpoly: self.errorpoly(), state, - occasion: self.occasion(), censoring: self.censoring(), } } @@ -777,7 +755,7 @@ mod tests { #[test] fn test_bolus_creation() { - let bolus = Bolus::new(2.5, 100.0, 1, 0); + let bolus = Bolus::new(2.5, 100.0, 1); assert_eq!(bolus.time(), 2.5); assert_eq!(bolus.amount(), 100.0); assert_eq!(bolus.input(), 1); @@ -786,7 +764,7 @@ mod tests { #[test] fn test_bolus_setters() { - let mut bolus = Bolus::new(2.5, 100.0, 1, 0); + let mut bolus = Bolus::new(2.5, 100.0, 1); bolus.set_time(3.0); assert_eq!(bolus.time(), 3.0); @@ -800,7 +778,7 @@ mod tests { #[test] fn test_infusion_creation() { - let infusion = Infusion::new(1.0, 200.0, 1, 2.5, 0); + let infusion = Infusion::new(1.0, 200.0, 1, 2.5); assert_eq!(infusion.time(), 1.0); assert_eq!(infusion.amount(), 200.0); assert_eq!(infusion.input(), 1); @@ -810,7 +788,7 @@ mod tests { #[test] fn test_infusion_setters() { - let mut infusion = Infusion::new(1.0, 200.0, 1, 2.5, 0); + let mut infusion = Infusion::new(1.0, 200.0, 1, 2.5); infusion.set_time(1.5); assert_eq!(infusion.time(), 1.5); @@ -828,7 +806,7 @@ mod tests { #[test] fn test_observation_creation() { let error_poly = Some(ErrorPoly::new(0.1, 0.2, 0.3, 0.4)); - let observation = Observation::new(5.0, Some(75.5), 2, error_poly, 0, Censor::None); + let observation = Observation::new(5.0, Some(75.5), 2, error_poly, Censor::None); assert_eq!(observation.time(), 5.0); assert_eq!(observation.value(), Some(75.5)); @@ -844,7 +822,6 @@ mod tests { Some(75.5), 2, Some(ErrorPoly::new(0.1, 0.2, 0.3, 0.4)), - 0, Censor::None, ); @@ -864,10 +841,10 @@ mod tests { #[test] fn test_event_time_operations() { - let mut bolus_event = Event::Bolus(Bolus::new(1.0, 100.0, 1, 0)); - let mut infusion_event = Event::Infusion(Infusion::new(2.0, 200.0, 1, 2.5, 0)); + let mut bolus_event = Event::Bolus(Bolus::new(1.0, 100.0, 1)); + let mut infusion_event = Event::Infusion(Infusion::new(2.0, 200.0, 1, 2.5)); let mut observation_event = - Event::Observation(Observation::new(3.0, Some(75.5), 2, None, 0, Censor::None)); + Event::Observation(Observation::new(3.0, Some(75.5), 2, None, Censor::None)); assert_eq!(bolus_event.time(), 1.0); assert_eq!(infusion_event.time(), 2.0); diff --git a/src/data/parser/pmetrics/csv.rs b/src/data/parser/pmetrics/csv.rs index 04a3997d..fcc260bd 100644 --- a/src/data/parser/pmetrics/csv.rs +++ b/src/data/parser/pmetrics/csv.rs @@ -251,15 +251,6 @@ fn validate_occasion( } let events = occasion.events(); - for event in events { - if event.occasion() != occasion_index { - return Err(unrepresentable(format!( - "subject `{}` has an event assigned to occasion {} inside occasion {occasion_index}", - subject.id(), - event.occasion() - ))); - } - } if events .windows(2) .any(|pair| pair[0].cmp_time_then_type(&pair[1]).is_gt()) diff --git a/src/data/parser/pmetrics/row.rs b/src/data/parser/pmetrics/row.rs index 163d5cb8..fcc52631 100644 --- a/src/data/parser/pmetrics/row.rs +++ b/src/data/parser/pmetrics/row.rs @@ -288,7 +288,6 @@ impl DataRow { self.out, outeq, self.get_errorpoly(), - 0, // occasion set later self.cens.unwrap_or(Censor::None), ))); } @@ -315,7 +314,6 @@ impl DataRow { id: self.id.clone(), time: self.time, })?, - 0, )) } else { // Bolus @@ -326,7 +324,6 @@ impl DataRow { time: self.time, })?, input, - 0, )) }; @@ -655,9 +652,6 @@ pub fn build_data(rows: impl IntoIterator) -> Result { assert_f64(left.amount(), right.amount()); @@ -611,7 +610,6 @@ fn negative_addl_reset_is_accepted_and_resets_at_earliest_expanded_dose() { .collect::>(), [-2.0, -1.0, 0.0] ); - assert!(occasion.events().iter().all(|event| event.occasion() == 1)); let bytes = data.to_pmetrics_csv_bytes().unwrap(); let rows = records(&bytes); diff --git a/src/data/structs.rs b/src/data/structs.rs index 40434cb5..f608afe3 100644 --- a/src/data/structs.rs +++ b/src/data/structs.rs @@ -224,7 +224,6 @@ impl Data { None, outeq.clone(), None, - occasion.index, Censor::None, ); new_events.push(Event::Observation(obs)); @@ -724,14 +723,13 @@ impl Occasion { errorpoly: Option, censored: Censor, ) { - let observation = - Observation::new(time, Some(value), outeq, errorpoly, self.index, censored); + let observation = Observation::new(time, Some(value), outeq, errorpoly, censored); self.add_event(Event::Observation(observation)); } /// Add a missing [Observation] event to the [Occasion] pub fn add_missing_observation(&mut self, time: f64, outeq: impl ToString) { - let observation = Observation::new(time, None, outeq, None, self.index, Censor::None); + let observation = Observation::new(time, None, outeq, None, Censor::None); self.add_event(Event::Observation(observation)); } @@ -746,26 +744,19 @@ impl Occasion { errorpoly: ErrorPoly, censored: Censor, ) { - let observation = Observation::new( - time, - Some(value), - outeq, - Some(errorpoly), - self.index, - censored, - ); + let observation = Observation::new(time, Some(value), outeq, Some(errorpoly), censored); self.add_event(Event::Observation(observation)); } /// Add a [Bolus] event to the [Occasion] pub fn add_bolus(&mut self, time: f64, amount: f64, input: impl ToString) { - let bolus = Bolus::new(time, amount, input, self.index); + let bolus = Bolus::new(time, amount, input); self.add_event(Event::Bolus(bolus)); } /// Add an [Infusion] event to the [Occasion] pub fn add_infusion(&mut self, time: f64, amount: f64, input: impl ToString, duration: f64) { - let infusion = Infusion::new(time, amount, input, duration, self.index); + let infusion = Infusion::new(time, amount, input, duration); self.add_event(Event::Infusion(infusion)); } @@ -1518,7 +1509,7 @@ mod tests { } // Test mutable reference iterator on a new event - let mut infusion_event = Event::Infusion(Infusion::new(5.0, 200.0, 1, 2.0, 2)); + let mut infusion_event = Event::Infusion(Infusion::new(5.0, 200.0, 1, 2.0)); let original_time = infusion_event.time(); for event in &mut infusion_event { diff --git a/src/simulator/equation/ode/closure.rs b/src/simulator/equation/ode/closure.rs index f189a319..662cafda 100644 --- a/src/simulator/equation/ode/closure.rs +++ b/src/simulator/equation/ode/closure.rs @@ -1144,7 +1144,7 @@ mod tests { #[test] fn pm_rhs_jvp_uses_absolute_time_and_active_infusion_rate() { let covariates = Covariates::default(); - let infusions = [Infusion::new(10.0, 3.0, 0, 1.0, 0)]; + let infusions = [Infusion::new(10.0, 3.0, 0, 1.0)]; let problem = PMProblem::with_params_v( |x, _p, t, dx, _bolus, rateiv, _cov| { dx[0] = (rateiv[0] + t) * x[0] * x[0]; @@ -1183,7 +1183,7 @@ mod tests { covariate.add_observation(1.0, 2.0); covariate.add_observation(2.0, 4.0); covariates.add_covariate("rate".into(), covariate); - let infusions = [Infusion::new(0.0, 1.0, 0, 1.0, 0)]; + let infusions = [Infusion::new(0.0, 1.0, 0, 1.0)]; let problem = PMProblem::with_params_v( |_x, _p, _t, dx, _bolus, _rateiv, _cov| dx[0] = 0.0, diff --git a/src/simulator/equation/ode/mod.rs b/src/simulator/equation/ode/mod.rs index daed0e90..6bc1acf9 100644 --- a/src/simulator/equation/ode/mod.rs +++ b/src/simulator/equation/ode/mod.rs @@ -2368,7 +2368,7 @@ mod tests { #[test] fn resolved_schedule_rejects_positive_nonzero_infusion_rate_underflow() { let amount = f64::from_bits(1); - let events = [Event::Infusion(Infusion::new(1.5, amount, "0", 2.0, 0))]; + let events = [Event::Infusion(Infusion::new(1.5, amount, "0", 2.0))]; let error = validate_resolved_ode_schedule(&events) .expect_err("positive nonzero infusion underflow must be rejected"); let message = error.to_string(); @@ -2381,7 +2381,7 @@ mod tests { #[test] fn resolved_schedule_rejects_negative_nonzero_infusion_rate_underflow() { let amount = -f64::from_bits(1); - let events = [Event::Infusion(Infusion::new(1.5, amount, "0", 2.0, 0))]; + let events = [Event::Infusion(Infusion::new(1.5, amount, "0", 2.0))]; let error = validate_resolved_ode_schedule(&events) .expect_err("negative nonzero infusion underflow must be rejected"); let message = error.to_string(); @@ -2393,7 +2393,7 @@ mod tests { #[test] fn resolved_schedule_accepts_zero_amount_infusion_with_zero_rate() { - let events = [Event::Infusion(Infusion::new(1.5, 0.0, "0", 2.0, 0))]; + let events = [Event::Infusion(Infusion::new(1.5, 0.0, "0", 2.0))]; assert_eq!( validate_resolved_ode_schedule(&events).expect("zero amount is material-free"), 1.5 diff --git a/src/simulator/likelihood/mod.rs b/src/simulator/likelihood/mod.rs index 62ee58b0..a82bf893 100644 --- a/src/simulator/likelihood/mod.rs +++ b/src/simulator/likelihood/mod.rs @@ -243,7 +243,6 @@ mod tests { outeq: 0, errorpoly: None, state: vec![10.5], - occasion: 0, censoring: Censor::None, }; @@ -279,7 +278,6 @@ mod tests { outeq: 0, errorpoly: None, state: vec![10.1], - occasion: 0, censoring: Censor::None, }, Prediction { @@ -289,7 +287,6 @@ mod tests { outeq: 0, errorpoly: None, state: vec![8.2], - occasion: 0, censoring: Censor::None, }, ]; @@ -326,7 +323,7 @@ mod tests { #[test] fn test_log_likelihood_combines_observations() { let mut preds = SubjectPredictions::default(); - let obs = Observation::new(0.0, Some(1.0), 0, None, 0, Censor::None); + let obs = Observation::new(0.0, Some(1.0), 0, None, Censor::None); preds.add_prediction(obs.to_prediction(1.0, vec![])); let error_model = AssayErrorModel::additive(ErrorPoly::new(1.0, 0.0, 0.0, 0.0), 0.0); diff --git a/src/simulator/likelihood/prediction.rs b/src/simulator/likelihood/prediction.rs index b1610f56..849fd549 100644 --- a/src/simulator/likelihood/prediction.rs +++ b/src/simulator/likelihood/prediction.rs @@ -22,7 +22,6 @@ pub struct Prediction { pub(crate) outeq: usize, pub(crate) errorpoly: Option, pub(crate) state: Vec, - pub(crate) occasion: usize, pub(crate) censoring: Censor, } @@ -157,16 +156,6 @@ impl Prediction { &self.state } - /// Get the occasion index - pub fn occasion(&self) -> usize { - self.occasion - } - - /// Get a mutable reference to the occasion index - pub fn mut_occasion(&mut self) -> &mut usize { - &mut self.occasion - } - /// Get the censoring status pub fn censoring(&self) -> Censor { self.censoring @@ -179,7 +168,6 @@ impl Prediction { self.observation, self.outeq, self.errorpoly, - self.occasion, self.censoring, ) } @@ -194,7 +182,6 @@ impl Default for Prediction { outeq: 0, errorpoly: None, state: vec![], - occasion: 0, censoring: Censor::None, } } @@ -227,7 +214,6 @@ mod tests { outeq: 0, errorpoly: None, state: vec![pred], - occasion: 0, censoring: Censor::None, } } diff --git a/src/simulator/likelihood/subject.rs b/src/simulator/likelihood/subject.rs index 05c1417f..389f499f 100644 --- a/src/simulator/likelihood/subject.rs +++ b/src/simulator/likelihood/subject.rs @@ -197,7 +197,7 @@ mod tests { #[test] fn test_log_likelihood_with_observations() { let mut preds = SubjectPredictions::default(); - let obs = Observation::new(0.0, Some(1.0), 0, None, 0, Censor::None); + let obs = Observation::new(0.0, Some(1.0), 0, None, Censor::None); preds.add_prediction(obs.to_prediction(1.0, vec![])); let error_model = AssayErrorModel::additive(ErrorPoly::new(1.0, 0.0, 0.0, 0.0), 0.0); @@ -218,7 +218,6 @@ mod tests { outeq: 0, errorpoly: None, state: vec![10.1], - occasion: 0, censoring: Censor::None, }, Prediction { @@ -228,7 +227,6 @@ mod tests { outeq: 0, errorpoly: None, state: vec![8.2], - occasion: 0, censoring: Censor::None, }, ];