From 006ac63e86f39b2b1bcebc0c15a18946887c936e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Sep 2026 15:05:27 +0000 Subject: [PATCH 1/3] Initial plan From f44dc34a05f4bdaf6029d0e5ee01a54f18b6b9a7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Sep 2026 15:11:47 +0000 Subject: [PATCH 2/3] Fail fast when requested drug block channel is not labelled in the model Co-authored-by: mirams <858776+mirams@users.noreply.github.com> --- src/single_cell/ApPredictMethods.cpp | 14 ++++++++++++++ test/TestApPredict.hpp | 15 +++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/single_cell/ApPredictMethods.cpp b/src/single_cell/ApPredictMethods.cpp index 33ef7d6..580befe 100644 --- a/src/single_cell/ApPredictMethods.cpp +++ b/src/single_cell/ApPredictMethods.cpp @@ -250,6 +250,20 @@ void ApPredictMethods::ReadInIC50HillAndSaturation( read_ic50s = true; } + // If the user has requested a block on this channel, but the model doesn't + // have this conductance labelled, throw straight away. Otherwise this + // wouldn't be picked up until we reach a concentration in the main loop + // that actually causes some block (i.e. a non-zero concentration), which + // can be confusing as the simulation appears to run fine for the first + // (often zero, "control") concentration(s) before failing later on. + if (read_ic50s && !mpModel->HasParameter(mMetadataNames[channelIdx]) && !mpModel->HasParameter(mMetadataNames[channelIdx] + "_scaling_factor")) + { + EXCEPTION( + mpModel->GetSystemName() + << " does not have the current \"" << mMetadataNames[channelIdx] + << "\" labelled, but you have requested a block on this channel."); + } + // Try loading any Hills if (p_args->OptionExists("--hill-" + channel)) { diff --git a/test/TestApPredict.hpp b/test/TestApPredict.hpp index a4ad694..0fcff00 100644 --- a/test/TestApPredict.hpp +++ b/test/TestApPredict.hpp @@ -123,6 +123,21 @@ class TestApPredict : public CxxTest::TestSuite TS_ASSERT_THROWS_THIS(SetupModel setup(1.0, UNSIGNED_UNSET), "Invalid file given with --cellml argument: bla.cellml"); } + { + // See https://github.com/Chaste/ApPredict/issues/3 - requesting a block on a + // channel that isn't labelled in the model should be picked up immediately, + // rather than only once we reach a concentration in the loop that actually + // causes some conductance change (which was confusing, as it could look like + // the simulation had run successfully for the earlier, e.g. zero, concentrations). + CommandLineArgumentsMocker wrapper("--model 1 --pacing-freq 1.0 --pacing-max-time 5 " + "--pic50-nal 1 --hill-nal 1 --saturation-nal 0 " + "--plasma-conc-high 100 --plasma-conc-low 0 " + "--plasma-conc-count 4 --plasma-conc-logscale true"); + + ApPredictMethods methods; + TS_ASSERT_THROWS_CONTAINS(methods.Run(), + "does not have the current \"membrane_persistent_sodium_current_conductance\" labelled, but you have requested a block on this channel."); + } } void TestVoltageThresholdDetectionAlgorithm() From b92f6c123f8f77091b631da2c77d277532471302 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 11 Sep 2026 16:54:11 +0000 Subject: [PATCH 3/3] Remove now-unreachable deferred exception in ApplyDrugBlock Co-authored-by: mirams <858776+mirams@users.noreply.github.com> --- src/single_cell/ApPredictMethods.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/single_cell/ApPredictMethods.cpp b/src/single_cell/ApPredictMethods.cpp index 580befe..e80a13d 100644 --- a/src/single_cell/ApPredictMethods.cpp +++ b/src/single_cell/ApPredictMethods.cpp @@ -413,16 +413,10 @@ void ApPredictMethods::ApplyDrugBlock( } else // We haven't got that conductance parameter, or at least it isn't labelled. { - // If we aren't trying to change it - don't worry, just carry on. - if (conductance_factor < 1) - { - // If the model hasn't got this channel conductance labelled, - // (but we are trying to change it) throw an error. - EXCEPTION( - pModel->GetSystemName() - << " does not have the current \"" << mMetadataNames[channel_index] - << "\" labelled, but you have requested a block on this channel."); - } + // We aren't trying to change it (ReadInIC50HillAndSaturation() already throws, + // before we ever get here, if a block was requested on a channel that isn't + // labelled in this model) - don't worry, just carry on. + assert(conductance_factor == 1.0); } }