Skip to content

Commit

Permalink
Change default ReturnData::status to AMICI_NOT_RUN (#1984)
Browse files Browse the repository at this point in the history
* Change default ReturnData::status to AMICI_NOT_RUN

So far, if a simulation with `runAmiciSimulations(...., failfast=True)` failed, an empty `ReturnData` with `status=AMICI_SUCCESS` was returned for the skipped conditions. This was rather confusing.

This adds a new status: `AMICI_NOT_RUN`.

Fixes #1949
  • Loading branch information
dweindl authored Feb 13, 2023
1 parent 4f6fc24 commit a075abf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions include/amici/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ constexpr int AMICI_DAMPING_FACTOR_ERROR= -86;
constexpr int AMICI_SINGULAR_JACOBIAN= -809;
constexpr int AMICI_NOT_IMPLEMENTED= -999;
constexpr int AMICI_MAX_TIME_EXCEEDED = -1000;
constexpr int AMICI_NOT_RUN= -1001;
constexpr int AMICI_SUCCESS= 0;
constexpr int AMICI_DATA_RETURN= 1;
constexpr int AMICI_ROOT_RETURN= 2;
Expand Down
3 changes: 2 additions & 1 deletion include/amici/rdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,9 @@ class ReturnData: public ModelDimensions {
* within the allowed time (see Solver.{set,get}MaxTime)
* * AMICI_ERROR, indicating that some error occurred during simulation
* (a more detailed error message will have been printed).
* * AMICI_NOT_RUN, if no simulation was started
*/
int status = 0;
int status = AMICI_NOT_RUN;

/** number of states (alias `nx_rdata`, kept for backward compatibility) */
int nx{0};
Expand Down
10 changes: 5 additions & 5 deletions python/examples/example_errors.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
" scaled_parameters=True\n",
")\n",
"print(\"Status:\", [amici.simulation_status_to_str(rdata.status) for rdata in res[RDATAS]])\n",
"assert [amici.simulation_status_to_str(rdata.status) for rdata in res[RDATAS]] == ['AMICI_SUCCESS', 'AMICI_SUCCESS', 'AMICI_SUCCESS', 'AMICI_TOO_MUCH_WORK', 'AMICI_SUCCESS', 'AMICI_SUCCESS']"
"assert [amici.simulation_status_to_str(rdata.status) for rdata in res[RDATAS]] == ['AMICI_SUCCESS', 'AMICI_SUCCESS', 'AMICI_SUCCESS', 'AMICI_TOO_MUCH_WORK', 'AMICI_NOT_RUN', 'AMICI_NOT_RUN']"
]
},
{
Expand Down Expand Up @@ -291,7 +291,7 @@
")\n",
"print(\"Status:\", [amici.simulation_status_to_str(rdata.status) for rdata in res[RDATAS]])\n",
"\n",
"assert [amici.simulation_status_to_str(rdata.status) for rdata in res[RDATAS]] == ['AMICI_SUCCESS', 'AMICI_ERR_FAILURE', 'AMICI_SUCCESS', 'AMICI_SUCCESS', 'AMICI_SUCCESS', 'AMICI_SUCCESS']"
"assert [amici.simulation_status_to_str(rdata.status) for rdata in res[RDATAS]] == ['AMICI_SUCCESS', 'AMICI_ERR_FAILURE', 'AMICI_NOT_RUN', 'AMICI_NOT_RUN', 'AMICI_NOT_RUN', 'AMICI_NOT_RUN']"
]
},
{
Expand Down Expand Up @@ -397,7 +397,7 @@
" scaled_parameters=True\n",
")\n",
"print(\"Status:\", [amici.simulation_status_to_str(rdata.status) for rdata in res[RDATAS]])\n",
"assert [amici.simulation_status_to_str(rdata.status) for rdata in res[RDATAS]] == ['AMICI_ERROR', 'AMICI_SUCCESS']"
"assert [amici.simulation_status_to_str(rdata.status) for rdata in res[RDATAS]] == ['AMICI_ERROR', 'AMICI_NOT_RUN']"
]
},
{
Expand Down Expand Up @@ -805,7 +805,7 @@
"\n",
"# hard to reproduce on GHA\n",
"if os.getenv('GITHUB_ACTIONS') is None:\n",
" assert [amici.simulation_status_to_str(rdata.status) for rdata in res[RDATAS]] == ['AMICI_ERROR', 'AMICI_SUCCESS', 'AMICI_SUCCESS', 'AMICI_SUCCESS', 'AMICI_SUCCESS', 'AMICI_SUCCESS', 'AMICI_SUCCESS', 'AMICI_SUCCESS']"
" assert [amici.simulation_status_to_str(rdata.status) for rdata in res[RDATAS]] == ['AMICI_ERROR', 'AMICI_NOT_RUN', 'AMICI_NOT_RUN', 'AMICI_NOT_RUN', 'AMICI_NOT_RUN', 'AMICI_NOT_RUN', 'AMICI_NOT_RUN', 'AMICI_NOT_RUN']"
]
},
{
Expand Down Expand Up @@ -947,7 +947,7 @@
"print(f\"{rdata.preeq_numsteps=}\")\n",
"# hard to reproduce on GHA\n",
"if os.getenv('GITHUB_ACTIONS') is None:\n",
" assert [amici.simulation_status_to_str(rdata.status) for rdata in res[RDATAS]] == ['AMICI_ERROR', 'AMICI_SUCCESS', 'AMICI_SUCCESS', 'AMICI_SUCCESS', 'AMICI_SUCCESS', 'AMICI_SUCCESS', 'AMICI_SUCCESS', 'AMICI_SUCCESS']"
" assert [amici.simulation_status_to_str(rdata.status) for rdata in res[RDATAS]] == ['AMICI_ERROR', 'AMICI_NOT_RUN', 'AMICI_NOT_RUN', 'AMICI_NOT_RUN', 'AMICI_NOT_RUN', 'AMICI_NOT_RUN', 'AMICI_NOT_RUN', 'AMICI_NOT_RUN']"
]
},
{
Expand Down
1 change: 1 addition & 0 deletions src/amici.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ std::map<int, std::string> simulation_status_to_str_map = {
{AMICI_NOT_IMPLEMENTED, "AMICI_NOT_IMPLEMENTED"},
{AMICI_MAX_TIME_EXCEEDED, "AMICI_MAX_TIME_EXCEEDED"},
{AMICI_SUCCESS, "AMICI_SUCCESS"},
{AMICI_NOT_RUN, "AMICI_NOT_RUN"},
};

std::unique_ptr<ReturnData> runAmiciSimulation(
Expand Down

0 comments on commit a075abf

Please sign in to comment.