refactor(python/composition): updated python comp bindings to use register model
This commit is contained in:
@@ -7,6 +7,8 @@
|
|||||||
#include "composition.h"
|
#include "composition.h"
|
||||||
#include "atomicSpecies.h"
|
#include "atomicSpecies.h"
|
||||||
|
|
||||||
|
#include "bindings.h"
|
||||||
|
|
||||||
namespace py = pybind11;
|
namespace py = pybind11;
|
||||||
|
|
||||||
std::string sv_to_string(std::string_view sv) {
|
std::string sv_to_string(std::string_view sv) {
|
||||||
@@ -19,12 +21,8 @@ std::string get_ostream_str(const composition::Composition& comp) {
|
|||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
PYBIND11_MODULE(fourdsse_bindings, m) { // Module name must match meson.build
|
|
||||||
m.doc() = "Python bindings for the 4DSSE project"; // Optional module docstring
|
|
||||||
|
|
||||||
auto comp_submodule = m.def_submodule("composition", "Bindings for the Composition module");
|
|
||||||
auto chem_submodule = m.def_submodule("species", "Bindings for the Chemical Species module");
|
|
||||||
|
|
||||||
|
void register_comp_bindings(pybind11::module &comp_submodule) {
|
||||||
// --- Bindings for composition and species module ---
|
// --- Bindings for composition and species module ---
|
||||||
py::class_<composition::GlobalComposition>(comp_submodule, "GlobalComposition")
|
py::class_<composition::GlobalComposition>(comp_submodule, "GlobalComposition")
|
||||||
.def_readonly("specificNumberDensity", &composition::GlobalComposition::specificNumberDensity)
|
.def_readonly("specificNumberDensity", &composition::GlobalComposition::specificNumberDensity)
|
||||||
@@ -135,6 +133,11 @@ PYBIND11_MODULE(fourdsse_bindings, m) { // Module name must match meson.build
|
|||||||
return get_ostream_str(comp); // Use helper for C++ operator<<
|
return get_ostream_str(comp); // Use helper for C++ operator<<
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void register_species_bindings(pybind11::module &chem_submodule) {
|
||||||
// --- Bindings for species module ---
|
// --- Bindings for species module ---
|
||||||
py::class_<chemSpecies::Species>(chem_submodule, "Species")
|
py::class_<chemSpecies::Species>(chem_submodule, "Species")
|
||||||
.def("mass", &chemSpecies::Species::mass, "Get atomic mass (amu)")
|
.def("mass", &chemSpecies::Species::mass, "Get atomic mass (amu)")
|
||||||
@@ -157,6 +160,4 @@ PYBIND11_MODULE(fourdsse_bindings, m) { // Module name must match meson.build
|
|||||||
});
|
});
|
||||||
|
|
||||||
chem_submodule.attr("species") = py::cast(chemSpecies::species); // Expose the species map
|
chem_submodule.attr("species") = py::cast(chemSpecies::species); // Expose the species map
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
6
src/python/composition/bindings.h
Normal file
6
src/python/composition/bindings.h
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <pybind11/pybind11.h>
|
||||||
|
|
||||||
|
void register_comp_bindings(pybind11::module &m);
|
||||||
|
void register_species_bindings(pybind11::module &m);
|
||||||
Reference in New Issue
Block a user