Skip to content

Commit

Permalink
Merge pull request #750 from nlmixr2/750-backward-warning
Browse files Browse the repository at this point in the history
With backward compatibility tests subscript of range warning
  • Loading branch information
mattfidler authored Aug 4, 2024
2 parents 8166f40 + 399c22c commit e79bd12
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/rxData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4897,7 +4897,13 @@ SEXP rxSolve_(const RObject &obj, const List &rxControl,
rxSolveFreeObj = object;
}
}

if (rxSolveDat->mv.size() == 0) {
// sometimes the model variables have not been assigned, but this
// needs to be assigned to set the user defined functions
// this is shown indirectly in the backward compatible testing
// where the subscript wasn't defined; See #750
rxSolveDat->mv = rxModelVars(object);
}
_rxode2_udfEnvSet(rxSolveDat->mv[RxMv_udf]);
LogicalVector recompileUdf = _rxode2_assignUdf(rxSolveDat->mv[RxMv_udf]);

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-backward.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ expect_error(rxode2("cp<-cent/vc;d/dt(gutcp)<--ka*gutcp;d/dt(cent)<-(ka*gutcp)-q
expect_equal(as.numeric(tmp$time[2]), 0.5)
expect_equal(as.numeric(x$time[2]), 1)
## $ access updates object.
x$add.sampling(0.5)
expect_warning(x$add.sampling(0.5), NA) # from issue #750
expect_equal(as.numeric(x$time[2]), 0.5)
})
x <- solve(mod1, theta, ev, inits)
Expand Down

0 comments on commit e79bd12

Please sign in to comment.