forked from SciCompMod/memilio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1105 redesign bindings structure to improve typing (SciCompMod#1106)
include python bindings for models and memilio core in the same python module with submodules to enable using core types in the models clean up directory structure: separate cpp binding code from python code fix small bugs in python binding code
- Loading branch information
1 parent
896a04e
commit 49ee2e8
Showing
51 changed files
with
319 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
38 changes: 38 additions & 0 deletions
38
pycode/memilio-simulation/memilio/simulation/bindings/epidemiology/age_group.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (C) 2020-2024 MEmilio | ||
* | ||
* Authors: Maximilian Betz | ||
* | ||
* Contact: Martin J. Kuehn <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#ifndef PYMIO_AGE_GROUP_H | ||
#define PYMIO_AGE_GROUP_H | ||
|
||
#include "memilio/epidemiology/age_group.h" | ||
|
||
#include "pybind11/pybind11.h" | ||
|
||
namespace pymio | ||
{ | ||
|
||
template <> | ||
inline std::string pretty_name<mio::AgeGroup>() | ||
{ | ||
return "AgeGroup"; | ||
} | ||
|
||
} // namespace pymio | ||
|
||
#endif //PYMIO_AGE_GROUP_H |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
38 changes: 38 additions & 0 deletions
38
pycode/memilio-simulation/memilio/simulation/bindings/epidemiology/simulation_day.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (C) 2020-2024 MEmilio | ||
* | ||
* Authors: Maximilian Betz | ||
* | ||
* Contact: Martin J. Kuehn <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#ifndef PYMIO_SIMULATION_DAY_H | ||
#define PYMIO_SIMULATION_DAY_H | ||
|
||
#include "memilio/epidemiology/simulation_day.h" | ||
|
||
#include "pybind11/pybind11.h" | ||
|
||
namespace pymio | ||
{ | ||
|
||
template <> | ||
inline std::string pretty_name<mio::SimulationDay>() | ||
{ | ||
return "SimulationDay"; | ||
} | ||
|
||
} // namespace pymio | ||
|
||
#endif //PYMIO_SIMULATION_DAY_H |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* Copyright (C) 2020-2024 MEmilio | ||
* | ||
* Authors: Martin Siggel, Daniel Abele, Martin J. Kuehn, Jan Kleinert, Khoa Nguyen | ||
* Authors: Martin Siggel, Daniel Abele, Martin J. Kuehn, Jan Kleinert | ||
* | ||
* Contact: Martin J. Kuehn <[email protected]> | ||
* | ||
|
@@ -19,11 +19,11 @@ | |
*/ | ||
|
||
//Includes from pymio | ||
#include "memilio/config.h" | ||
#include "pybind_util.h" | ||
#include "compartments/simulation.h" | ||
#include "compartments/flow_simulation.h" | ||
#include "compartments/compartmentalmodel.h" | ||
#include "epidemiology/age_group.h" | ||
#include "epidemiology/populations.h" | ||
#include "utils/custom_index_array.h" | ||
#include "utils/parameter_set.h" | ||
|
@@ -43,6 +43,7 @@ | |
#include "memilio/mobility/graph.h" | ||
#include "memilio/io/mobility_io.h" | ||
#include "memilio/io/epi_data.h" | ||
#include "memilio/config.h" | ||
|
||
#include "pybind11/pybind11.h" | ||
#include "pybind11/stl_bind.h" | ||
|
@@ -150,26 +151,19 @@ using MobilityGraph = mio::Graph<mio::SimulationNode<mio::osecir::Simulation<>>, | |
|
||
} // namespace | ||
|
||
PYBIND11_MAKE_OPAQUE(std::vector<MobilityGraph>); | ||
|
||
namespace pymio | ||
{ | ||
|
||
//specialization of pretty_name | ||
template <> | ||
std::string pretty_name<mio::osecir::InfectionState>() | ||
inline std::string pretty_name<mio::osecir::InfectionState>() | ||
{ | ||
return "InfectionState"; | ||
} | ||
|
||
template <> | ||
std::string pretty_name<mio::AgeGroup>() | ||
{ | ||
return "AgeGroup"; | ||
} | ||
|
||
} // namespace pymio | ||
|
||
PYBIND11_MAKE_OPAQUE(std::vector<MobilityGraph>); | ||
|
||
PYBIND11_MODULE(_simulation_osecir, m) | ||
{ | ||
// https://github.com/pybind/pybind11/issues/1153 | ||
|
@@ -289,7 +283,7 @@ PYBIND11_MODULE(_simulation_osecir, m) | |
mio::Graph<mio::osecir::Model<double>, mio::MobilityParameters<double>>& params_graph, | ||
size_t contact_locations_size) { | ||
auto mobile_comp = {mio::osecir::InfectionState::Susceptible, mio::osecir::InfectionState::Exposed, | ||
mio::osecir::InfectionState::InfectedNoSymptoms, | ||
mio::osecir::InfectionState::InfectedNoSymptoms, | ||
mio::osecir::InfectionState::InfectedSymptoms, mio::osecir::InfectionState::Recovered}; | ||
auto weights = std::vector<ScalarType>{0., 0., 1.0, 1.0, 0.33, 0., 0.}; | ||
auto result = mio::set_edges<ContactLocation, mio::osecir::Model<double>, mio::MobilityParameters<double>, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.