Skip to content

Commit 17b29a0

Browse files
authored
Add symbol names to python-wrapped models and make them available in python (Closes #64) (#346)
* core() Add symbol names to python-wrapped models and make them available in python (Closes #64) * feature(core) add functions to check for set symbol names * Rewrap test models * ci(osx) Let osx build fail until #348 is resolved * ci(osx) go back to standard brew python * ci() move buildAmici to script
1 parent f1e8756 commit 17b29a0

File tree

14 files changed

+142
-24
lines changed

14 files changed

+142
-24
lines changed

.travis.yml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ branches:
77
- staging
88

99
matrix:
10+
fast_finish: true
1011
include:
1112
- os: linux
1213
dist: xenial
@@ -38,9 +39,9 @@ matrix:
3839
- brew update # without this homebrew can stumble over wrong ruby version
3940
- travis_wait brew install gcc || brew link --overwrite gcc # fix linker warning regarding /usr/local/include/c++
4041
- brew install hdf5 cppcheck swig doxygen ragel graphviz homebrew/cask/mactex
41-
- brew install zoidbergwill/python/python36
42+
- brew upgrade python
4243
after_success:
43-
- cd $BASE_DIR # cd to base dir for correct relative pah in deploy
44+
- cd $BASE_DIR # cd to base dir for correct relative path in deploy
4445
deploy:
4546
provider: pages
4647
local-dir: doc
@@ -50,24 +51,46 @@ matrix:
5051
verbose: true
5152
on:
5253
branch: master
53-
54+
55+
allow_failures:
56+
# allow osx build to fail until symengine/homebrew/python3.7 issue is resolved
57+
- os: osx
58+
osx_image: xcode9.3
59+
compiler: clang
60+
before_install:
61+
- brew update # without this homebrew can stumble over wrong ruby version
62+
- travis_wait brew install gcc || brew link --overwrite gcc # fix linker warning regarding /usr/local/include/c++
63+
- brew install hdf5 cppcheck swig doxygen ragel graphviz homebrew/cask/mactex
64+
- brew upgrade python
65+
after_success:
66+
- cd $BASE_DIR # cd to base dir for correct relative path in deploy
67+
deploy:
68+
provider: pages
69+
local-dir: doc
70+
skip-cleanup: true
71+
github-token: $GITHUB_TOKEN # Set in the settings page of your repository, as a secure variable
72+
keep-history: false
73+
verbose: true
74+
on:
75+
branch: master
76+
5477
install:
5578
# Python distutils only looks for `swig` and does not find `swig3.0`
5679
- export BASE_DIR=`pwd`
5780
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mkdir -p ~/bin/ && ln -s /usr/bin/swig3.0 ~/bin/swig && export PATH=~/bin/:$PATH; fi
58-
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then pyenv versions; fi
81+
- pyenv versions
5982
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then pyenv shell 2.7 3.6; fi
6083
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH=/Users/travis/Library/Python/3.6/bin:$PATH; fi
6184
- pip3 install --user --upgrade pip setuptools wheel pkgconfig doxypypy coverage scipy
6285
- ./scripts/buildSuiteSparse.sh
6386
- ./scripts/buildSundials.sh
6487
- ./scripts/buildCpputest.sh
65-
- ./scripts/buildAmici.sh
6688

6789
script:
6890
# - cd $BASE_DIR/python/sdist
6991
# - python3 setup.py sdist --dist-dir=$BASE_DIR/build/python/
7092
# - python3 -m pip install $BASE_DIR/build/python/amici-*.tar.gz --verbose
93+
- ./scripts/buildAmici.sh
7194
- cd $BASE_DIR
7295
- ./scripts/run-cpputest.sh
7396
- ./scripts/run-cppcheck.sh

include/amici/model.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,56 @@ namespace amici {
504504
*/
505505
int checkFinite(const int N,const realtype *array, const char* fun) const;
506506

507+
508+
/**
509+
* @brief Reports whether the model has parameter names set.
510+
* @return
511+
*/
512+
virtual bool hasParameterNames() const { return np() && !getParameterNames().empty(); }
513+
514+
/**
515+
* @brief Get names of the model parameters
516+
* @return the names
517+
*/
518+
virtual std::vector<std::string> getParameterNames() const { return std::vector<std::string>(); }
519+
520+
521+
/**
522+
* @brief Reports whether the model has state names set.
523+
* @return
524+
*/
525+
virtual bool hasStateNames() const { return nx && !getStateNames().empty(); }
526+
527+
/**
528+
* @brief Get names of the model states
529+
* @return the names
530+
*/
531+
virtual std::vector<std::string> getStateNames() const { return std::vector<std::string>(); }
532+
533+
/**
534+
* @brief Reports whether the model has fixed parameter names set.
535+
* @return
536+
*/
537+
virtual bool hasFixedParameterNames() const { return nk() && !getFixedParameterNames().empty(); }
538+
539+
/**
540+
* @brief Get names of the fixed model parameters
541+
* @return the names
542+
*/
543+
virtual std::vector<std::string> getFixedParameterNames() const { return std::vector<std::string>(); }
544+
545+
/**
546+
* @brief Reports whether the model has observable names set.
547+
* @return
548+
*/
549+
virtual bool hasObservableNames() const { return ny && !getObservableNames().empty(); }
550+
551+
/**
552+
* @brief Get names of the observables
553+
* @return the names
554+
*/
555+
virtual std::vector<std::string> getObservableNames() const { return std::vector<std::string>(); }
556+
507557
/** number of states */
508558
const int nx;
509559
/** number of states in the unaugmented system */

models/model_dirac/model_dirac.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#ifndef _amici_model_dirac_h
22
#define _amici_model_dirac_h
3-
/* Generated by amiwrap (R2017b) 413f6c54d956e878a95406f02808fafd1272c1cd */
3+
/* Generated by amiwrap (R2017b) f1e875655d8b056a0adf3c71f583fe988f257a06 */
44
#include <cmath>
55
#include <memory>
66
#include "amici/defines.h"
@@ -62,7 +62,7 @@ class Model_model_dirac : public amici::Model_ODE {
6262

6363
virtual amici::Model* clone() const override { return new Model_model_dirac(*this); };
6464

65-
const char* getAmiciVersion() const { return "413f6c54d956e878a95406f02808fafd1272c1cd"; };
65+
const char* getAmiciVersion() const { return "f1e875655d8b056a0adf3c71f583fe988f257a06"; };
6666

6767
virtual void fJ(realtype *J, const realtype t, const realtype *x, const double *p, const double *k, const realtype *h, const realtype *w, const realtype *dwdx) override {
6868
J_model_dirac(J, t, x, p, k, h, w, dwdx);

models/model_events/model_events.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#ifndef _amici_model_events_h
22
#define _amici_model_events_h
3-
/* Generated by amiwrap (R2017b) 413f6c54d956e878a95406f02808fafd1272c1cd */
3+
/* Generated by amiwrap (R2017b) f1e875655d8b056a0adf3c71f583fe988f257a06 */
44
#include <cmath>
55
#include <memory>
66
#include "amici/defines.h"
@@ -76,7 +76,7 @@ class Model_model_events : public amici::Model_ODE {
7676

7777
virtual amici::Model* clone() const override { return new Model_model_events(*this); };
7878

79-
const char* getAmiciVersion() const { return "413f6c54d956e878a95406f02808fafd1272c1cd"; };
79+
const char* getAmiciVersion() const { return "f1e875655d8b056a0adf3c71f583fe988f257a06"; };
8080

8181
virtual void fJ(realtype *J, const realtype t, const realtype *x, const double *p, const double *k, const realtype *h, const realtype *w, const realtype *dwdx) override {
8282
J_model_events(J, t, x, p, k, h, w, dwdx);

models/model_jakstat_adjoint/model_jakstat_adjoint.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#ifndef _amici_model_jakstat_adjoint_h
22
#define _amici_model_jakstat_adjoint_h
3-
/* Generated by amiwrap (R2017b) 413f6c54d956e878a95406f02808fafd1272c1cd */
3+
/* Generated by amiwrap (R2017b) f1e875655d8b056a0adf3c71f583fe988f257a06 */
44
#include <cmath>
55
#include <memory>
66
#include "amici/defines.h"
@@ -65,7 +65,7 @@ class Model_model_jakstat_adjoint : public amici::Model_ODE {
6565

6666
virtual amici::Model* clone() const override { return new Model_model_jakstat_adjoint(*this); };
6767

68-
const char* getAmiciVersion() const { return "413f6c54d956e878a95406f02808fafd1272c1cd"; };
68+
const char* getAmiciVersion() const { return "f1e875655d8b056a0adf3c71f583fe988f257a06"; };
6969

7070
virtual void fJ(realtype *J, const realtype t, const realtype *x, const double *p, const double *k, const realtype *h, const realtype *w, const realtype *dwdx) override {
7171
J_model_jakstat_adjoint(J, t, x, p, k, h, w, dwdx);

models/model_jakstat_adjoint_o2/model_jakstat_adjoint_o2.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#ifndef _amici_model_jakstat_adjoint_o2_h
22
#define _amici_model_jakstat_adjoint_o2_h
3-
/* Generated by amiwrap (R2017b) 413f6c54d956e878a95406f02808fafd1272c1cd */
3+
/* Generated by amiwrap (R2017b) f1e875655d8b056a0adf3c71f583fe988f257a06 */
44
#include <cmath>
55
#include <memory>
66
#include "amici/defines.h"
@@ -65,7 +65,7 @@ class Model_model_jakstat_adjoint_o2 : public amici::Model_ODE {
6565

6666
virtual amici::Model* clone() const override { return new Model_model_jakstat_adjoint_o2(*this); };
6767

68-
const char* getAmiciVersion() const { return "413f6c54d956e878a95406f02808fafd1272c1cd"; };
68+
const char* getAmiciVersion() const { return "f1e875655d8b056a0adf3c71f583fe988f257a06"; };
6969

7070
virtual void fJ(realtype *J, const realtype t, const realtype *x, const double *p, const double *k, const realtype *h, const realtype *w, const realtype *dwdx) override {
7171
J_model_jakstat_adjoint_o2(J, t, x, p, k, h, w, dwdx);

models/model_nested_events/model_nested_events.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#ifndef _amici_model_nested_events_h
22
#define _amici_model_nested_events_h
3-
/* Generated by amiwrap (R2017b) 413f6c54d956e878a95406f02808fafd1272c1cd */
3+
/* Generated by amiwrap (R2017b) f1e875655d8b056a0adf3c71f583fe988f257a06 */
44
#include <cmath>
55
#include <memory>
66
#include "amici/defines.h"
@@ -65,7 +65,7 @@ class Model_model_nested_events : public amici::Model_ODE {
6565

6666
virtual amici::Model* clone() const override { return new Model_model_nested_events(*this); };
6767

68-
const char* getAmiciVersion() const { return "413f6c54d956e878a95406f02808fafd1272c1cd"; };
68+
const char* getAmiciVersion() const { return "f1e875655d8b056a0adf3c71f583fe988f257a06"; };
6969

7070
virtual void fJ(realtype *J, const realtype t, const realtype *x, const double *p, const double *k, const realtype *h, const realtype *w, const realtype *dwdx) override {
7171
J_model_nested_events(J, t, x, p, k, h, w, dwdx);

models/model_neuron/model_neuron.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#ifndef _amici_model_neuron_h
22
#define _amici_model_neuron_h
3-
/* Generated by amiwrap (R2017b) 413f6c54d956e878a95406f02808fafd1272c1cd */
3+
/* Generated by amiwrap (R2017b) f1e875655d8b056a0adf3c71f583fe988f257a06 */
44
#include <cmath>
55
#include <memory>
66
#include "amici/defines.h"
@@ -79,7 +79,7 @@ class Model_model_neuron : public amici::Model_ODE {
7979

8080
virtual amici::Model* clone() const override { return new Model_model_neuron(*this); };
8181

82-
const char* getAmiciVersion() const { return "413f6c54d956e878a95406f02808fafd1272c1cd"; };
82+
const char* getAmiciVersion() const { return "f1e875655d8b056a0adf3c71f583fe988f257a06"; };
8383

8484
virtual void fJ(realtype *J, const realtype t, const realtype *x, const double *p, const double *k, const realtype *h, const realtype *w, const realtype *dwdx) override {
8585
J_model_neuron(J, t, x, p, k, h, w, dwdx);

models/model_neuron_o2/model_neuron_o2.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#ifndef _amici_model_neuron_o2_h
22
#define _amici_model_neuron_o2_h
3-
/* Generated by amiwrap (R2017b) 413f6c54d956e878a95406f02808fafd1272c1cd */
3+
/* Generated by amiwrap (R2017b) f1e875655d8b056a0adf3c71f583fe988f257a06 */
44
#include <cmath>
55
#include <memory>
66
#include "amici/defines.h"
@@ -81,7 +81,7 @@ class Model_model_neuron_o2 : public amici::Model_ODE {
8181

8282
virtual amici::Model* clone() const override { return new Model_model_neuron_o2(*this); };
8383

84-
const char* getAmiciVersion() const { return "413f6c54d956e878a95406f02808fafd1272c1cd"; };
84+
const char* getAmiciVersion() const { return "f1e875655d8b056a0adf3c71f583fe988f257a06"; };
8585

8686
virtual void fJ(realtype *J, const realtype t, const realtype *x, const double *p, const double *k, const realtype *h, const realtype *w, const realtype *dwdx) override {
8787
J_model_neuron_o2(J, t, x, p, k, h, w, dwdx);

models/model_robertson/model_robertson.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#ifndef _amici_model_robertson_h
22
#define _amici_model_robertson_h
3-
/* Generated by amiwrap (R2017b) 413f6c54d956e878a95406f02808fafd1272c1cd */
3+
/* Generated by amiwrap (R2017b) f1e875655d8b056a0adf3c71f583fe988f257a06 */
44
#include <cmath>
55
#include <memory>
66
#include "amici/defines.h"
@@ -63,7 +63,7 @@ class Model_model_robertson : public amici::Model_DAE {
6363

6464
virtual amici::Model* clone() const override { return new Model_model_robertson(*this); };
6565

66-
const char* getAmiciVersion() const { return "413f6c54d956e878a95406f02808fafd1272c1cd"; };
66+
const char* getAmiciVersion() const { return "f1e875655d8b056a0adf3c71f583fe988f257a06"; };
6767

6868
virtual void fJ(realtype *J, const realtype t, const realtype *x, const double *p, const double *k, const realtype *h, const realtype cj, const realtype *dx, const realtype *w, const realtype *dwdx) override {
6969
J_model_robertson(J, t, x, p, k, h, cj, dx, w, dwdx);

0 commit comments

Comments
 (0)