diff --git a/python/cxx/unit_system.cpp b/python/cxx/unit_system.cpp index e675e8b83..640fd7c0e 100644 --- a/python/cxx/unit_system.cpp +++ b/python/cxx/unit_system.cpp @@ -1,3 +1,5 @@ +#include + #include #include "export.hpp" @@ -7,4 +9,17 @@ void python::common::export_UnitSystem(py::module& module) { py::class_(module, "UnitSystem") .def_property_readonly( "name", &UnitSystem::getName ); + + + py::class_(module, "Dimension") + .def_property_readonly("scaling", &Dimension::getSIScaling) + .def_property_readonly("offset", &Dimension::getSIOffset) + .def("__repr__", [](const Dimension& dim) { + auto scaling = dim.getSIScaling(); + auto offset = dim.getSIOffset(); + if (dim.getSIOffset() != 0) + return fmt::format("Dimension(scaling={}, offset={})", scaling, offset); + else + return fmt::format("Dimension(scaling={})", scaling); + }); } diff --git a/python/opm/_common.py b/python/opm/_common.py index 8721a5647..3596551dc 100644 --- a/python/opm/_common.py +++ b/python/opm/_common.py @@ -14,6 +14,7 @@ from .libopmcommon_python import action from .libopmcommon_python import Parser, ParseContext, Builtin, eclSectionType from .libopmcommon_python import DeckKeyword from .libopmcommon_python import DeckItem +from .libopmcommon_python import Dimension from .libopmcommon_python import UnitSystem from .libopmcommon_python import EclipseState diff --git a/python/opm/io/__init__.py b/python/opm/io/__init__.py index b23b081cb..7a967ffdb 100644 --- a/python/opm/io/__init__.py +++ b/python/opm/io/__init__.py @@ -1,2 +1,4 @@ from .parser import * from .log import * +from opm._common import UnitSystem +from opm._common import Dimension