From 434e7bee3cac39106a0e1752207108d2c962a4d7 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Mon, 8 Jan 2024 19:07:58 +0100 Subject: [PATCH] Add ExpData::clear_observations (#2258) Makes it more convenient to unset all measurements, e.g. if one wants to run a simulation for a given experimental condition but with additional output timepoints while ignoring previously set measuremnts. --- include/amici/edata.h | 7 +++++++ src/edata.cpp | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/amici/edata.h b/include/amici/edata.h index 78bcba0fc7..5d613c6262 100644 --- a/include/amici/edata.h +++ b/include/amici/edata.h @@ -390,6 +390,13 @@ class ExpData : public SimulationParameters { */ realtype const* getObservedEventsStdDevPtr(int ie) const; + /** + * @brief Set all observations and their standard deviations to NaN. + * + * Useful, e.g., after calling ExpData::setTimepoints. + */ + void clear_observations(); + /** * @brief Arbitrary (not necessarily unique) identifier. */ diff --git a/src/edata.cpp b/src/edata.cpp index b9f95fca97..05499bb9cf 100644 --- a/src/edata.cpp +++ b/src/edata.cpp @@ -338,6 +338,18 @@ realtype const* ExpData::getObservedEventsStdDevPtr(int ie) const { return nullptr; } +void ExpData::clear_observations() { + std::fill(observed_data_.begin(), observed_data_.end(), getNaN()); + std::fill( + observed_data_std_dev_.begin(), observed_data_std_dev_.end(), getNaN() + ); + std::fill(observed_events_.begin(), observed_events_.end(), getNaN()); + std::fill( + observed_events_std_dev_.begin(), observed_events_std_dev_.end(), + getNaN() + ); +} + void ExpData::applyDimensions() { applyDataDimension(); applyEventDimension();