From 1ce331d5c4b486e92bad9c905a5690db87a86918 Mon Sep 17 00:00:00 2001 From: Rikard Nordgren Date: Mon, 16 Oct 2023 08:37:15 +0200 Subject: [PATCH] Check if refcorr defined before using --- lib/tool/npc.pm | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/tool/npc.pm b/lib/tool/npc.pm index 36c2aba1..7a0f699a 100644 --- a/lib/tool/npc.pm +++ b/lib/tool/npc.pm @@ -1594,18 +1594,20 @@ sub modelfit_setup problem_numbers => [$self->simprobnum()]); $model_sims[$i] -> _write(relative_data_path => $self->copy_data); - my %refcorr = %{$self->refcorr}; - if (%refcorr) { - my $num = $i + 1; - my $path = "m1/" . $model_sims[$i]->filename; - my $destpath = "m1/${type}_simulation_refcorr.$num.mod"; - my $refstr = ""; - for my $k (keys %refcorr) { - $refstr .= "$k=" . $refcorr{$k}; - } - PsN::call_pharmpy("data reference $path -o $destpath $refstr"); - my $refmodel = model->new(filename => $destpath); - push @refcorr_models, $refmodel; + if (defined $self->refcorr) { + my %refcorr = %{$self->refcorr}; + if (%refcorr) { + my $num = $i + 1; + my $path = "m1/" . $model_sims[$i]->filename; + my $destpath = "m1/${type}_simulation_refcorr.$num.mod"; + my $refstr = ""; + for my $k (keys %refcorr) { + $refstr .= "$k=" . $refcorr{$k}; + } + PsN::call_pharmpy("data reference $path -o $destpath $refstr"); + my $refmodel = model->new(filename => $destpath); + push @refcorr_models, $refmodel; + } } } $model_orig -> remove_records(type => 'simulation');