Skip to content

Commit

Permalink
Fix get_model for direct import of swig interface (#1969)
Browse files Browse the repository at this point in the history
Fixup for #1932

This fixes importing the swig wrapper for a model directly (not via the package).
  • Loading branch information
dweindl authored Jan 31, 2023
1 parent b61abb6 commit a43ae7f
Show file tree
Hide file tree
Showing 31 changed files with 123 additions and 22 deletions.
4 changes: 2 additions & 2 deletions models/model_calvetti/model_calvetti.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef _amici_model_calvetti_h
#define _amici_model_calvetti_h
/* Generated by amiwrap (R2017b) b04ab2326fb34f3721a15806d9783ff22b6a015a */
/* Generated by amiwrap (R2017b) b61abb6cf09df7b484efe45bb8e378ac07d2b33b */
#include <cmath>
#include <memory>
#include "amici/defines.h"
Expand Down Expand Up @@ -70,7 +70,7 @@ class Model_model_calvetti : public amici::Model_DAE {

amici::Model* clone() const override { return new Model_model_calvetti(*this); };

std::string getAmiciCommit() const override { return "b04ab2326fb34f3721a15806d9783ff22b6a015a"; };
std::string getAmiciCommit() const override { return "b61abb6cf09df7b484efe45bb8e378ac07d2b33b"; };

void fJSparse(SUNMatrixContent_Sparse JSparse, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype cj, const realtype *dx, const realtype *w, const realtype *dwdx) override {
JSparse_model_calvetti(JSparse, t, x, p, k, h, cj, dx, w, dwdx);
Expand Down
2 changes: 2 additions & 0 deletions models/model_calvetti/swig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
include_directories(${PYTHON_INCLUDE_DIRS})
set(Python3_LIBRARIES ${PYTHON_LIBRARIES})
else()
# We don't need "Interpreter" here, but without that, FindPython3 will
# ignore the Python version selected via $Python3_EXECUTABLE
find_package(Python3 COMPONENTS Interpreter Development)
include_directories(${Python3_INCLUDE_DIRS})
endif()
Expand Down
8 changes: 8 additions & 0 deletions models/model_calvetti/swig/model_calvetti.i
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,13 @@ using namespace amici;
%}


// Make model module accessible from the model
%feature("pythonappend") amici::generic_model::getModel %{
if '.' in __name__:
import sys
val.module = sys.modules['.'.join(__name__.split('.')[:-1])]
%}


// Process symbols in header
%include "wrapfunctions.h"
4 changes: 2 additions & 2 deletions models/model_dirac/model_dirac.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef _amici_model_dirac_h
#define _amici_model_dirac_h
/* Generated by amiwrap (R2017b) b04ab2326fb34f3721a15806d9783ff22b6a015a */
/* Generated by amiwrap (R2017b) b61abb6cf09df7b484efe45bb8e378ac07d2b33b */
#include <cmath>
#include <memory>
#include "amici/defines.h"
Expand Down Expand Up @@ -70,7 +70,7 @@ class Model_model_dirac : public amici::Model_ODE {

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

std::string getAmiciCommit() const override { return "b04ab2326fb34f3721a15806d9783ff22b6a015a"; };
std::string getAmiciCommit() const override { return "b61abb6cf09df7b484efe45bb8e378ac07d2b33b"; };

void fJSparse(SUNMatrixContent_Sparse JSparse, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx) override {
JSparse_model_dirac(JSparse, t, x, p, k, h, w, dwdx);
Expand Down
2 changes: 2 additions & 0 deletions models/model_dirac/swig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
include_directories(${PYTHON_INCLUDE_DIRS})
set(Python3_LIBRARIES ${PYTHON_LIBRARIES})
else()
# We don't need "Interpreter" here, but without that, FindPython3 will
# ignore the Python version selected via $Python3_EXECUTABLE
find_package(Python3 COMPONENTS Interpreter Development)
include_directories(${Python3_INCLUDE_DIRS})
endif()
Expand Down
8 changes: 8 additions & 0 deletions models/model_dirac/swig/model_dirac.i
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,13 @@ using namespace amici;
%}


// Make model module accessible from the model
%feature("pythonappend") amici::generic_model::getModel %{
if '.' in __name__:
import sys
val.module = sys.modules['.'.join(__name__.split('.')[:-1])]
%}


// Process symbols in header
%include "wrapfunctions.h"
4 changes: 2 additions & 2 deletions models/model_events/model_events.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef _amici_model_events_h
#define _amici_model_events_h
/* Generated by amiwrap (R2017b) b04ab2326fb34f3721a15806d9783ff22b6a015a */
/* Generated by amiwrap (R2017b) b61abb6cf09df7b484efe45bb8e378ac07d2b33b */
#include <cmath>
#include <memory>
#include "amici/defines.h"
Expand Down Expand Up @@ -84,7 +84,7 @@ class Model_model_events : public amici::Model_ODE {

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

std::string getAmiciCommit() const override { return "b04ab2326fb34f3721a15806d9783ff22b6a015a"; };
std::string getAmiciCommit() const override { return "b61abb6cf09df7b484efe45bb8e378ac07d2b33b"; };

void fJSparse(SUNMatrixContent_Sparse JSparse, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx) override {
JSparse_model_events(JSparse, t, x, p, k, h, w, dwdx);
Expand Down
2 changes: 2 additions & 0 deletions models/model_events/swig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
include_directories(${PYTHON_INCLUDE_DIRS})
set(Python3_LIBRARIES ${PYTHON_LIBRARIES})
else()
# We don't need "Interpreter" here, but without that, FindPython3 will
# ignore the Python version selected via $Python3_EXECUTABLE
find_package(Python3 COMPONENTS Interpreter Development)
include_directories(${Python3_INCLUDE_DIRS})
endif()
Expand Down
8 changes: 8 additions & 0 deletions models/model_events/swig/model_events.i
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,13 @@ using namespace amici;
%}


// Make model module accessible from the model
%feature("pythonappend") amici::generic_model::getModel %{
if '.' in __name__:
import sys
val.module = sys.modules['.'.join(__name__.split('.')[:-1])]
%}


// Process symbols in header
%include "wrapfunctions.h"
4 changes: 2 additions & 2 deletions models/model_jakstat_adjoint/model_jakstat_adjoint.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef _amici_model_jakstat_adjoint_h
#define _amici_model_jakstat_adjoint_h
/* Generated by amiwrap (R2017b) b04ab2326fb34f3721a15806d9783ff22b6a015a */
/* Generated by amiwrap (R2017b) b61abb6cf09df7b484efe45bb8e378ac07d2b33b */
#include <cmath>
#include <memory>
#include "amici/defines.h"
Expand Down Expand Up @@ -73,7 +73,7 @@ class Model_model_jakstat_adjoint : public amici::Model_ODE {

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

std::string getAmiciCommit() const override { return "b04ab2326fb34f3721a15806d9783ff22b6a015a"; };
std::string getAmiciCommit() const override { return "b61abb6cf09df7b484efe45bb8e378ac07d2b33b"; };

void fJSparse(SUNMatrixContent_Sparse JSparse, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx) override {
JSparse_model_jakstat_adjoint(JSparse, t, x, p, k, h, w, dwdx);
Expand Down
2 changes: 2 additions & 0 deletions models/model_jakstat_adjoint/swig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
include_directories(${PYTHON_INCLUDE_DIRS})
set(Python3_LIBRARIES ${PYTHON_LIBRARIES})
else()
# We don't need "Interpreter" here, but without that, FindPython3 will
# ignore the Python version selected via $Python3_EXECUTABLE
find_package(Python3 COMPONENTS Interpreter Development)
include_directories(${Python3_INCLUDE_DIRS})
endif()
Expand Down
8 changes: 8 additions & 0 deletions models/model_jakstat_adjoint/swig/model_jakstat_adjoint.i
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,13 @@ using namespace amici;
%}


// Make model module accessible from the model
%feature("pythonappend") amici::generic_model::getModel %{
if '.' in __name__:
import sys
val.module = sys.modules['.'.join(__name__.split('.')[:-1])]
%}


// Process symbols in header
%include "wrapfunctions.h"
4 changes: 2 additions & 2 deletions models/model_jakstat_adjoint_o2/model_jakstat_adjoint_o2.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef _amici_model_jakstat_adjoint_o2_h
#define _amici_model_jakstat_adjoint_o2_h
/* Generated by amiwrap (R2017b) b04ab2326fb34f3721a15806d9783ff22b6a015a */
/* Generated by amiwrap (R2017b) b61abb6cf09df7b484efe45bb8e378ac07d2b33b */
#include <cmath>
#include <memory>
#include "amici/defines.h"
Expand Down Expand Up @@ -73,7 +73,7 @@ class Model_model_jakstat_adjoint_o2 : public amici::Model_ODE {

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

std::string getAmiciCommit() const override { return "b04ab2326fb34f3721a15806d9783ff22b6a015a"; };
std::string getAmiciCommit() const override { return "b61abb6cf09df7b484efe45bb8e378ac07d2b33b"; };

void fJSparse(SUNMatrixContent_Sparse JSparse, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx) override {
JSparse_model_jakstat_adjoint_o2(JSparse, t, x, p, k, h, w, dwdx);
Expand Down
2 changes: 2 additions & 0 deletions models/model_jakstat_adjoint_o2/swig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
include_directories(${PYTHON_INCLUDE_DIRS})
set(Python3_LIBRARIES ${PYTHON_LIBRARIES})
else()
# We don't need "Interpreter" here, but without that, FindPython3 will
# ignore the Python version selected via $Python3_EXECUTABLE
find_package(Python3 COMPONENTS Interpreter Development)
include_directories(${Python3_INCLUDE_DIRS})
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,13 @@ using namespace amici;
%}


// Make model module accessible from the model
%feature("pythonappend") amici::generic_model::getModel %{
if '.' in __name__:
import sys
val.module = sys.modules['.'.join(__name__.split('.')[:-1])]
%}


// Process symbols in header
%include "wrapfunctions.h"
4 changes: 2 additions & 2 deletions models/model_nested_events/model_nested_events.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef _amici_model_nested_events_h
#define _amici_model_nested_events_h
/* Generated by amiwrap (R2017b) b04ab2326fb34f3721a15806d9783ff22b6a015a */
/* Generated by amiwrap (R2017b) b61abb6cf09df7b484efe45bb8e378ac07d2b33b */
#include <cmath>
#include <memory>
#include "amici/defines.h"
Expand Down Expand Up @@ -73,7 +73,7 @@ class Model_model_nested_events : public amici::Model_ODE {

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

std::string getAmiciCommit() const override { return "b04ab2326fb34f3721a15806d9783ff22b6a015a"; };
std::string getAmiciCommit() const override { return "b61abb6cf09df7b484efe45bb8e378ac07d2b33b"; };

void fJSparse(SUNMatrixContent_Sparse JSparse, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx) override {
JSparse_model_nested_events(JSparse, t, x, p, k, h, w, dwdx);
Expand Down
2 changes: 2 additions & 0 deletions models/model_nested_events/swig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
include_directories(${PYTHON_INCLUDE_DIRS})
set(Python3_LIBRARIES ${PYTHON_LIBRARIES})
else()
# We don't need "Interpreter" here, but without that, FindPython3 will
# ignore the Python version selected via $Python3_EXECUTABLE
find_package(Python3 COMPONENTS Interpreter Development)
include_directories(${Python3_INCLUDE_DIRS})
endif()
Expand Down
8 changes: 8 additions & 0 deletions models/model_nested_events/swig/model_nested_events.i
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,13 @@ using namespace amici;
%}


// Make model module accessible from the model
%feature("pythonappend") amici::generic_model::getModel %{
if '.' in __name__:
import sys
val.module = sys.modules['.'.join(__name__.split('.')[:-1])]
%}


// Process symbols in header
%include "wrapfunctions.h"
4 changes: 2 additions & 2 deletions models/model_neuron/model_neuron.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef _amici_model_neuron_h
#define _amici_model_neuron_h
/* Generated by amiwrap (R2017b) b04ab2326fb34f3721a15806d9783ff22b6a015a */
/* Generated by amiwrap (R2017b) b61abb6cf09df7b484efe45bb8e378ac07d2b33b */
#include <cmath>
#include <memory>
#include "amici/defines.h"
Expand Down Expand Up @@ -87,7 +87,7 @@ class Model_model_neuron : public amici::Model_ODE {

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

std::string getAmiciCommit() const override { return "b04ab2326fb34f3721a15806d9783ff22b6a015a"; };
std::string getAmiciCommit() const override { return "b61abb6cf09df7b484efe45bb8e378ac07d2b33b"; };

void fJSparse(SUNMatrixContent_Sparse JSparse, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx) override {
JSparse_model_neuron(JSparse, t, x, p, k, h, w, dwdx);
Expand Down
2 changes: 2 additions & 0 deletions models/model_neuron/swig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
include_directories(${PYTHON_INCLUDE_DIRS})
set(Python3_LIBRARIES ${PYTHON_LIBRARIES})
else()
# We don't need "Interpreter" here, but without that, FindPython3 will
# ignore the Python version selected via $Python3_EXECUTABLE
find_package(Python3 COMPONENTS Interpreter Development)
include_directories(${Python3_INCLUDE_DIRS})
endif()
Expand Down
8 changes: 8 additions & 0 deletions models/model_neuron/swig/model_neuron.i
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,13 @@ using namespace amici;
%}


// Make model module accessible from the model
%feature("pythonappend") amici::generic_model::getModel %{
if '.' in __name__:
import sys
val.module = sys.modules['.'.join(__name__.split('.')[:-1])]
%}


// Process symbols in header
%include "wrapfunctions.h"
4 changes: 2 additions & 2 deletions models/model_neuron_o2/model_neuron_o2.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef _amici_model_neuron_o2_h
#define _amici_model_neuron_o2_h
/* Generated by amiwrap (R2017b) b04ab2326fb34f3721a15806d9783ff22b6a015a */
/* Generated by amiwrap (R2017b) b61abb6cf09df7b484efe45bb8e378ac07d2b33b */
#include <cmath>
#include <memory>
#include "amici/defines.h"
Expand Down Expand Up @@ -89,7 +89,7 @@ class Model_model_neuron_o2 : public amici::Model_ODE {

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

std::string getAmiciCommit() const override { return "b04ab2326fb34f3721a15806d9783ff22b6a015a"; };
std::string getAmiciCommit() const override { return "b61abb6cf09df7b484efe45bb8e378ac07d2b33b"; };

void fJSparse(SUNMatrixContent_Sparse JSparse, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx) override {
JSparse_model_neuron_o2(JSparse, t, x, p, k, h, w, dwdx);
Expand Down
2 changes: 2 additions & 0 deletions models/model_neuron_o2/swig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
include_directories(${PYTHON_INCLUDE_DIRS})
set(Python3_LIBRARIES ${PYTHON_LIBRARIES})
else()
# We don't need "Interpreter" here, but without that, FindPython3 will
# ignore the Python version selected via $Python3_EXECUTABLE
find_package(Python3 COMPONENTS Interpreter Development)
include_directories(${Python3_INCLUDE_DIRS})
endif()
Expand Down
8 changes: 8 additions & 0 deletions models/model_neuron_o2/swig/model_neuron_o2.i
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,13 @@ using namespace amici;
%}


// Make model module accessible from the model
%feature("pythonappend") amici::generic_model::getModel %{
if '.' in __name__:
import sys
val.module = sys.modules['.'.join(__name__.split('.')[:-1])]
%}


// Process symbols in header
%include "wrapfunctions.h"
4 changes: 2 additions & 2 deletions models/model_robertson/model_robertson.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef _amici_model_robertson_h
#define _amici_model_robertson_h
/* Generated by amiwrap (R2017b) b04ab2326fb34f3721a15806d9783ff22b6a015a */
/* Generated by amiwrap (R2017b) b61abb6cf09df7b484efe45bb8e378ac07d2b33b */
#include <cmath>
#include <memory>
#include "amici/defines.h"
Expand Down Expand Up @@ -71,7 +71,7 @@ class Model_model_robertson : public amici::Model_DAE {

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

std::string getAmiciCommit() const override { return "b04ab2326fb34f3721a15806d9783ff22b6a015a"; };
std::string getAmiciCommit() const override { return "b61abb6cf09df7b484efe45bb8e378ac07d2b33b"; };

void fJSparse(SUNMatrixContent_Sparse JSparse, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype cj, const realtype *dx, const realtype *w, const realtype *dwdx) override {
JSparse_model_robertson(JSparse, t, x, p, k, h, cj, dx, w, dwdx);
Expand Down
2 changes: 2 additions & 0 deletions models/model_robertson/swig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
include_directories(${PYTHON_INCLUDE_DIRS})
set(Python3_LIBRARIES ${PYTHON_LIBRARIES})
else()
# We don't need "Interpreter" here, but without that, FindPython3 will
# ignore the Python version selected via $Python3_EXECUTABLE
find_package(Python3 COMPONENTS Interpreter Development)
include_directories(${Python3_INCLUDE_DIRS})
endif()
Expand Down
8 changes: 8 additions & 0 deletions models/model_robertson/swig/model_robertson.i
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,13 @@ using namespace amici;
%}


// Make model module accessible from the model
%feature("pythonappend") amici::generic_model::getModel %{
if '.' in __name__:
import sys
val.module = sys.modules['.'.join(__name__.split('.')[:-1])]
%}


// Process symbols in header
%include "wrapfunctions.h"
4 changes: 2 additions & 2 deletions models/model_steadystate/model_steadystate.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef _amici_model_steadystate_h
#define _amici_model_steadystate_h
/* Generated by amiwrap (R2017b) b04ab2326fb34f3721a15806d9783ff22b6a015a */
/* Generated by amiwrap (R2017b) b61abb6cf09df7b484efe45bb8e378ac07d2b33b */
#include <cmath>
#include <memory>
#include "amici/defines.h"
Expand Down Expand Up @@ -70,7 +70,7 @@ class Model_model_steadystate : public amici::Model_ODE {

amici::Model* clone() const override { return new Model_model_steadystate(*this); };

std::string getAmiciCommit() const override { return "b04ab2326fb34f3721a15806d9783ff22b6a015a"; };
std::string getAmiciCommit() const override { return "b61abb6cf09df7b484efe45bb8e378ac07d2b33b"; };

void fJSparse(SUNMatrixContent_Sparse JSparse, const realtype t, const realtype *x, const realtype *p, const realtype *k, const realtype *h, const realtype *w, const realtype *dwdx) override {
JSparse_model_steadystate(JSparse, t, x, p, k, h, w, dwdx);
Expand Down
2 changes: 2 additions & 0 deletions models/model_steadystate/swig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
include_directories(${PYTHON_INCLUDE_DIRS})
set(Python3_LIBRARIES ${PYTHON_LIBRARIES})
else()
# We don't need "Interpreter" here, but without that, FindPython3 will
# ignore the Python version selected via $Python3_EXECUTABLE
find_package(Python3 COMPONENTS Interpreter Development)
include_directories(${Python3_INCLUDE_DIRS})
endif()
Expand Down
8 changes: 8 additions & 0 deletions models/model_steadystate/swig/model_steadystate.i
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,13 @@ using namespace amici;
%}


// Make model module accessible from the model
%feature("pythonappend") amici::generic_model::getModel %{
if '.' in __name__:
import sys
val.module = sys.modules['.'.join(__name__.split('.')[:-1])]
%}


// Process symbols in header
%include "wrapfunctions.h"
Loading

0 comments on commit a43ae7f

Please sign in to comment.