@@ -211,13 +211,13 @@ install(DIRECTORY cmake DESTINATION share/opm)
|
||||
install(FILES etc/opm_bash_completion.sh.in DESTINATION share/opm/etc)
|
||||
|
||||
if (OPM_ENABLE_PYTHON)
|
||||
|
||||
find_package(PythonInterp REQUIRED)
|
||||
include(FindPythonInterp)
|
||||
|
||||
make_directory(${CMAKE_BINARY_DIR}/python)
|
||||
if (EXISTS "/etc/debian_version")
|
||||
set( PYTHON_PACKAGE_PATH "dist-packages")
|
||||
else()
|
||||
set( PYTHON_PACKAGE_PATH "site-packages")
|
||||
endif()
|
||||
set(PYTHON_INSTALL_PREFIX "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/${PYTHON_PACKAGE_PATH}/sunbeam" CACHE STRING "Subdirectory to install Python modules in")
|
||||
set(PYTHON_PACKAGE_PATH "site-packages")
|
||||
set(PYTHON_INSTALL_PREFIX "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/${PYTHON_PACKAGE_PATH}" CACHE STRING "Subdirectory to install Python modules in")
|
||||
|
||||
get_target_property(_ecl_include_dirs ecl INTERFACE_INCLUDE_DIRECTORIES)
|
||||
get_target_property(_opmcommon_include_dirs opmcommon INCLUDE_DIRECTORIES)
|
||||
@@ -229,7 +229,7 @@ if (OPM_ENABLE_PYTHON)
|
||||
set(_opmcommon_lib_dirs ${_ecl_lib_dir} ${CMAKE_BINARY_DIR}/lib ${CMAKE_PREFIX_PATH}/lib)
|
||||
string(REPLACE ";" ":" _setup_lib_dirs "${_opmcommon_lib_dirs}")
|
||||
|
||||
add_custom_command(OUTPUT python/python/sunbeam/libsunbeam.so
|
||||
add_custom_command(OUTPUT python/python/opm/libopmcommon_python.so
|
||||
DEPENDS python/cxx/connection.cpp
|
||||
python/cxx/converters.hpp
|
||||
python/cxx/deck.cpp
|
||||
@@ -242,28 +242,30 @@ if (OPM_ENABLE_PYTHON)
|
||||
python/cxx/group_tree.cpp
|
||||
python/cxx/parser.cpp
|
||||
python/cxx/schedule.cpp
|
||||
python/cxx/sunbeam.cpp
|
||||
python/cxx/sunbeam.hpp
|
||||
python/cxx/sunbeam_state.cpp
|
||||
python/cxx/sunbeam_state.hpp
|
||||
python/cxx/common.cpp
|
||||
python/cxx/common.hpp
|
||||
python/cxx/common_state.cpp
|
||||
python/cxx/common_state.hpp
|
||||
python/cxx/table_manager.cpp
|
||||
python/cxx/well.cpp
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/python/ ${CMAKE_BINARY_DIR}/python
|
||||
COMMAND python ${CMAKE_BINARY_DIR}/python/setup.py
|
||||
build
|
||||
build_ext
|
||||
--build-lib=${CMAKE_BINARY_DIR}/python/python/sunbeam
|
||||
--build-lib=${CMAKE_BINARY_DIR}/python/python/opm
|
||||
--library-dirs=${_setup_lib_dirs}
|
||||
--include-dirs=${_setup_include_dirs}
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/python
|
||||
COMMENT "Building python bindings")
|
||||
add_custom_target(sunbeam ALL DEPENDS python/python/sunbeam/libsunbeam.so)
|
||||
add_dependencies(sunbeam opmcommon)
|
||||
INSTALL( DIRECTORY ${CMAKE_BINARY_DIR}/python/python/sunbeam/ DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX})
|
||||
add_custom_target(opmcommon_python ALL DEPENDS python/python/opm/libopmcommon_python.so)
|
||||
add_dependencies(opmcommon_python opmcommon)
|
||||
|
||||
install( CODE "execute_process(COMMAND mkdir -p ${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX} )" )
|
||||
install( CODE "execute_process(COMMAND python python/setup.py build_ext --dry-run install --prefix=${CMAKE_INSTALL_PREFIX} )" )
|
||||
|
||||
add_test(NAME python_tests
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/python
|
||||
COMMAND python setup.py build_ext --dry-run --build-lib ${CMAKE_BINARY_DIR}/python/python/sunbeam test
|
||||
COMMAND python setup.py build_ext --dry-run --build-lib ${CMAKE_BINARY_DIR}/python/python/opm test
|
||||
)
|
||||
|
||||
set_target_properties(opmcommon PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
20
python/cxx/common.cpp
Normal file
20
python/cxx/common.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <pybind11/pybind11.h>
|
||||
#include "common.hpp"
|
||||
|
||||
|
||||
PYBIND11_MODULE(libopmcommon_python, module) {
|
||||
opmcommon_python::export_Parser(module);
|
||||
opmcommon_python::export_Deck(module);
|
||||
opmcommon_python::export_DeckKeyword(module);
|
||||
opmcommon_python::export_Schedule(module);
|
||||
opmcommon_python::export_Well(module);
|
||||
opmcommon_python::export_Group(module);
|
||||
opmcommon_python::export_GroupTree(module);
|
||||
opmcommon_python::export_Connection(module);
|
||||
opmcommon_python::export_EclipseConfig(module);
|
||||
opmcommon_python::export_Eclipse3DProperties(module);
|
||||
opmcommon_python::export_EclipseState(module);
|
||||
opmcommon_python::export_TableManager(module);
|
||||
opmcommon_python::export_EclipseGrid(module);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ const py::return_value_policy ref_internal = py::return_value_policy::reference_
|
||||
const py::return_value_policy python_owner = py::return_value_policy::take_ownership;
|
||||
const py::return_value_policy move = py::return_value_policy::move;
|
||||
|
||||
namespace sunbeam {
|
||||
namespace opmcommon_python {
|
||||
|
||||
void export_Connection(py::module& module);
|
||||
void export_Deck(py::module& module);
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "sunbeam_state.hpp"
|
||||
#include "common_state.hpp"
|
||||
|
||||
|
||||
SunbeamState::SunbeamState(bool file_input, const std::string& deck_input, const Opm::ParseContext& context, const Opm::Parser& parser)
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Connection.hpp>
|
||||
|
||||
#include "sunbeam.hpp"
|
||||
#include "common.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -15,7 +15,7 @@ std::string direction( const Connection& c ) {
|
||||
}
|
||||
|
||||
|
||||
void sunbeam::export_Connection(py::module& module) {
|
||||
void opmcommon_python::export_Connection(py::module& module) {
|
||||
|
||||
py::class_< Connection >( module, "Connection")
|
||||
.def_property_readonly("direction", &direction )
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <pybind11/pybind11.h>
|
||||
#include "converters.hpp"
|
||||
#include "sunbeam.hpp"
|
||||
#include "common.hpp"
|
||||
|
||||
|
||||
namespace {
|
||||
@@ -37,7 +37,7 @@ namespace {
|
||||
|
||||
}
|
||||
|
||||
void sunbeam::export_Deck(py::module &module) {
|
||||
void opmcommon_python::export_Deck(py::module &module) {
|
||||
|
||||
py::class_< Deck >(module, "Deck")
|
||||
.def( "__len__", &size )
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
|
||||
#include <opm/parser/eclipse/Utility/Typetools.hpp>
|
||||
|
||||
#include "sunbeam.hpp"
|
||||
#include "common.hpp"
|
||||
#include "converters.hpp"
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ struct DeckRecordIterator
|
||||
|
||||
}
|
||||
|
||||
void sunbeam::export_DeckKeyword(py::module& module) {
|
||||
void opmcommon_python::export_DeckKeyword(py::module& module) {
|
||||
py::class_< DeckKeyword >( module, "DeckKeyword")
|
||||
.def( "__repr__", &DeckKeyword::name )
|
||||
.def( "__str__", &str<DeckKeyword> )
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
#include "sunbeam.hpp"
|
||||
#include "common.hpp"
|
||||
#include "converters.hpp"
|
||||
|
||||
namespace {
|
||||
@@ -35,7 +35,7 @@ namespace {
|
||||
|
||||
}
|
||||
|
||||
void sunbeam::export_Eclipse3DProperties(py::module& module) {
|
||||
void opmcommon_python::export_Eclipse3DProperties(py::module& module) {
|
||||
|
||||
py::class_< Eclipse3DProperties >( module, "Eclipse3DProperties")
|
||||
.def( "getRegions", ®ions )
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
#include <opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp>
|
||||
|
||||
#include "sunbeam.hpp"
|
||||
#include "common.hpp"
|
||||
|
||||
|
||||
void sunbeam::export_EclipseConfig(py::module& module)
|
||||
void opmcommon_python::export_EclipseConfig(py::module& module)
|
||||
{
|
||||
py::class_< EclipseConfig >( module, "EclipseConfig" )
|
||||
.def( "init", &EclipseConfig::init, ref_internal)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/Fault.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/FaceDir.hpp>
|
||||
|
||||
#include "sunbeam.hpp"
|
||||
#include "common.hpp"
|
||||
|
||||
|
||||
namespace {
|
||||
@@ -41,7 +41,7 @@ namespace {
|
||||
|
||||
}
|
||||
|
||||
void sunbeam::export_EclipseGrid(py::module& module) {
|
||||
void opmcommon_python::export_EclipseGrid(py::module& module) {
|
||||
|
||||
py::class_< EclipseGrid >( module, "EclipseGrid")
|
||||
.def( "_getXYZ", &getXYZ )
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/FaultCollection.hpp>
|
||||
|
||||
#include "sunbeam.hpp"
|
||||
#include "common.hpp"
|
||||
|
||||
|
||||
namespace {
|
||||
@@ -85,7 +85,7 @@ namespace {
|
||||
|
||||
}
|
||||
|
||||
void sunbeam::export_EclipseState(py::module& module) {
|
||||
void opmcommon_python::export_EclipseState(py::module& module) {
|
||||
|
||||
py::class_< EclipseState >( module, "EclipseState" )
|
||||
.def_property_readonly( "title", &EclipseState::getTitle )
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/Group2.hpp>
|
||||
#include <pybind11/stl.h>
|
||||
#include "sunbeam.hpp"
|
||||
#include "common.hpp"
|
||||
|
||||
|
||||
namespace {
|
||||
@@ -14,7 +14,7 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
void sunbeam::export_Group(py::module& module) {
|
||||
void opmcommon_python::export_Group(py::module& module) {
|
||||
|
||||
py::class_< Group2 >( module, "Group")
|
||||
.def_property_readonly( "name", &Group2::name)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Group/GTNode.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
|
||||
|
||||
#include "sunbeam.hpp"
|
||||
#include "common.hpp"
|
||||
#include "converters.hpp"
|
||||
|
||||
namespace {
|
||||
@@ -15,7 +15,7 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
void sunbeam::export_GroupTree(py::module& module) {
|
||||
void opmcommon_python::export_GroupTree(py::module& module) {
|
||||
|
||||
py::class_<GTNode>(module, "GroupTree")
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
#include "sunbeam_state.hpp"
|
||||
#include "sunbeam.hpp"
|
||||
#include "common_state.hpp"
|
||||
#include "common.hpp"
|
||||
|
||||
|
||||
namespace {
|
||||
@@ -46,7 +46,7 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
void sunbeam::export_Parser(py::module& module) {
|
||||
void opmcommon_python::export_Parser(py::module& module) {
|
||||
|
||||
module.def( "parse", parse_file );
|
||||
module.def( "parse_string", parse_string);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <pybind11/stl.h>
|
||||
#include <pybind11/chrono.h>
|
||||
#include "sunbeam.hpp"
|
||||
#include "common.hpp"
|
||||
|
||||
|
||||
namespace {
|
||||
@@ -90,7 +90,7 @@ namespace {
|
||||
|
||||
}
|
||||
|
||||
void sunbeam::export_Schedule(py::module& module) {
|
||||
void opmcommon_python::export_Schedule(py::module& module) {
|
||||
|
||||
py::class_< Schedule >( module, "Schedule")
|
||||
.def("_groups", &get_groups )
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#include <pybind11/pybind11.h>
|
||||
#include "sunbeam.hpp"
|
||||
|
||||
|
||||
PYBIND11_MODULE(libsunbeam, module) {
|
||||
sunbeam::export_Parser(module);
|
||||
sunbeam::export_Deck(module);
|
||||
sunbeam::export_DeckKeyword(module);
|
||||
sunbeam::export_Schedule(module);
|
||||
sunbeam::export_Well(module);
|
||||
sunbeam::export_Group(module);
|
||||
sunbeam::export_GroupTree(module);
|
||||
sunbeam::export_Connection(module);
|
||||
sunbeam::export_EclipseConfig(module);
|
||||
sunbeam::export_Eclipse3DProperties(module);
|
||||
sunbeam::export_EclipseState(module);
|
||||
sunbeam::export_TableManager(module);
|
||||
sunbeam::export_EclipseGrid(module);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
|
||||
|
||||
#include "sunbeam.hpp"
|
||||
#include "common.hpp"
|
||||
|
||||
|
||||
namespace {
|
||||
@@ -16,7 +16,7 @@ namespace {
|
||||
|
||||
}
|
||||
|
||||
void sunbeam::export_TableManager(py::module& module) {
|
||||
void opmcommon_python::export_TableManager(py::module& module) {
|
||||
|
||||
py::class_< TableManager >( module, "Tables")
|
||||
.def( "__contains__", &TableManager::hasTables )
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <opm/parser/eclipse/EclipseState/Schedule/Well/Well2.hpp>
|
||||
#include <pybind11/stl.h>
|
||||
#include "sunbeam.hpp"
|
||||
#include "common.hpp"
|
||||
|
||||
|
||||
namespace {
|
||||
@@ -33,7 +33,7 @@ namespace {
|
||||
|
||||
}
|
||||
|
||||
void sunbeam::export_Well(py::module& module) {
|
||||
void opmcommon_python::export_Well(py::module& module) {
|
||||
|
||||
py::class_< Well2 >( module, "Well")
|
||||
.def_property_readonly( "name", &Well2::name )
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
from .schedule import Well, Connection, Schedule
|
||||
from .libsunbeam import action
|
||||
from .schedule import Well, Connection, Schedule
|
||||
from .libopmcommon_python import action
|
||||
from .config import EclipseConfig
|
||||
from .parser import parse, parse_string
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
from sunbeam import libsunbeam as lib
|
||||
from opm import libopmcommon_python as lib
|
||||
from .sunbeam import delegate
|
||||
|
||||
@delegate(lib.SummaryConfig)
|
||||
2
python/python/opm/deck/__init__.py
Normal file
2
python/python/opm/deck/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from opm.parser import load_deck as parse
|
||||
from opm.parser import load_deck_string as parse_string
|
||||
@@ -2,7 +2,7 @@ from __future__ import absolute_import
|
||||
import os.path
|
||||
import json
|
||||
|
||||
from sunbeam import libsunbeam as lib
|
||||
from opm import libopmcommon_python as lib
|
||||
from .properties import SunbeamState
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from __future__ import absolute_import
|
||||
from os.path import isfile
|
||||
|
||||
from sunbeam import libsunbeam as lib
|
||||
from opm import libopmcommon_python as lib
|
||||
from .sunbeam import delegate
|
||||
from .schedule import Schedule
|
||||
from .config import EclipseConfig
|
||||
@@ -1,6 +1,6 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
from sunbeam import libsunbeam as lib
|
||||
from opm import libopmcommon_python as lib
|
||||
from .sunbeam import delegate
|
||||
|
||||
@delegate(lib.Schedule)
|
||||
@@ -6,7 +6,7 @@ except ImportError:
|
||||
from io import StringIO
|
||||
|
||||
|
||||
import sunbeam.deck
|
||||
import opm.deck
|
||||
|
||||
# This is from the TimeMap.cpp implementation in opm
|
||||
ecl_month = {"JAN" : 1,
|
||||
@@ -172,7 +172,7 @@ class TimeVector(object):
|
||||
Basic usage example:
|
||||
|
||||
#!/usr/bin/env python
|
||||
from sunbeam.tools import TimeVector
|
||||
from opm.tools import TimeVector
|
||||
|
||||
# Create vector and load history.
|
||||
tv = TimeVector( start )
|
||||
@@ -213,11 +213,11 @@ class TimeVector(object):
|
||||
self._add_dates_block(ts)
|
||||
start_dt = datetime.datetime(start_date.year, start_date.month, start_date.day)
|
||||
if base_file:
|
||||
deck = sunbeam.deck.parse(base_file)
|
||||
deck = opm.deck.parse(base_file)
|
||||
self._add_deck(deck, start_dt)
|
||||
|
||||
if base_string:
|
||||
deck = sunbeam.deck.parse_string(base_string)
|
||||
deck = opm.deck.parse_string(base_string)
|
||||
self._add_deck(deck, start_dt)
|
||||
|
||||
|
||||
@@ -328,7 +328,7 @@ class TimeVector(object):
|
||||
tv.load("well.sch", date = datetime.datetime(2017, 4, 1))
|
||||
|
||||
"""
|
||||
deck = sunbeam.deck.parse(filename)
|
||||
deck = opm.deck.parse(filename)
|
||||
self._add_deck(deck, date)
|
||||
|
||||
|
||||
@@ -336,7 +336,7 @@ class TimeVector(object):
|
||||
"""
|
||||
Like load() - but load from a string literal instead of file.
|
||||
"""
|
||||
deck = sunbeam.deck.parse_string(deck_string)
|
||||
deck = opm.deck.parse_string(deck_string)
|
||||
self._add_deck(deck, date)
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
from sunbeam.parser import load_deck as parse
|
||||
from sunbeam.parser import load_deck_string as parse_string
|
||||
@@ -8,6 +8,29 @@ import setuptools
|
||||
import glob
|
||||
import os
|
||||
import subprocess
|
||||
import argparse
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("build")
|
||||
parser.add_argument("build_ext")
|
||||
parser.add_argument("--build-lib")
|
||||
parser.add_argument("--prefix")
|
||||
parser.add_argument("--library-dirs")
|
||||
parser.add_argument("--include-dirs")
|
||||
parser.add_argument("--dry-run", action='store_true')
|
||||
args = parser.parse_args()
|
||||
|
||||
#Circumnventing setuptools' PYTHONPATH check.
|
||||
#This is necessary during install
|
||||
if args.prefix:
|
||||
python_version = 'python' + str(sys.version_info.major) + '.' + str(sys.version_info.minor)
|
||||
pkg_path_root = os.path.join(args.prefix, 'lib', python_version, 'site-packages')
|
||||
os.environ['PYTHONPATH'] += ':' + pkg_path_root
|
||||
|
||||
setupdir = os.path.dirname(__file__)
|
||||
if setupdir != '':
|
||||
os.chdir( setupdir )
|
||||
|
||||
try:
|
||||
subprocess.call(["c++", "--version"])
|
||||
@@ -22,7 +45,7 @@ if 'build' in sys.argv:
|
||||
|
||||
ext_modules = [
|
||||
Extension(
|
||||
'libsunbeam',
|
||||
'libopmcommon_python',
|
||||
[
|
||||
'cxx/connection.cpp',
|
||||
'cxx/deck.cpp',
|
||||
@@ -35,10 +58,10 @@ ext_modules = [
|
||||
'cxx/group_tree.cpp',
|
||||
'cxx/parser.cpp',
|
||||
'cxx/schedule.cpp',
|
||||
'cxx/sunbeam_state.cpp',
|
||||
'cxx/common_state.cpp',
|
||||
'cxx/table_manager.cpp',
|
||||
'cxx/well.cpp',
|
||||
'cxx/sunbeam.cpp'
|
||||
'cxx/common.cpp'
|
||||
],
|
||||
libraries=['opmcommon', 'boost_filesystem', 'boost_regex', 'ecl'],
|
||||
language='c++',
|
||||
@@ -48,16 +71,20 @@ ext_modules = [
|
||||
]
|
||||
|
||||
setup(
|
||||
name='Sunbeam',
|
||||
name='Opm',
|
||||
package_dir = {'': 'python'},
|
||||
packages=[
|
||||
'sunbeam',
|
||||
'sunbeam.tools',
|
||||
'sunbeam.deck',
|
||||
'opm',
|
||||
'opm.tools',
|
||||
'opm.deck',
|
||||
],
|
||||
ext_modules=ext_modules,
|
||||
package_data={
|
||||
'': ['cxx/libopmcommon_python.so']
|
||||
},
|
||||
include_package_data=True,
|
||||
license='Open Source',
|
||||
zip_safe=False,
|
||||
test_suite='tests',
|
||||
tests_suite='tests',
|
||||
setup_requires=["pytest-runner", 'setuptools_scm'],
|
||||
)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import unittest
|
||||
import sunbeam
|
||||
import opm
|
||||
|
||||
class TestWells(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.sch = sunbeam.parse('tests/spe3/SPE3CASE1.DATA').schedule
|
||||
cls.sch = opm.parse('tests/spe3/SPE3CASE1.DATA').schedule
|
||||
cls.timesteps = cls.sch.timesteps
|
||||
|
||||
def test_connection_pos(self):
|
||||
@@ -26,8 +26,8 @@ class TestWells(unittest.TestCase):
|
||||
self.assertEqual("OPEN", connection.state)
|
||||
|
||||
def test_filters(self):
|
||||
flowing = sunbeam.Connection.flowing()
|
||||
closed = sunbeam.Connection.closed()
|
||||
flowing = opm.Connection.flowing()
|
||||
closed = opm.Connection.closed()
|
||||
connections = self.sch.get_wells(0)[0].connections()
|
||||
self.assertEqual(len(list(filter(flowing, connections))), 2)
|
||||
self.assertEqual(len(list(filter(closed, connections))), 0)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import unittest
|
||||
import sunbeam.deck
|
||||
import opm.deck
|
||||
|
||||
class TestParse(unittest.TestCase):
|
||||
|
||||
@@ -27,7 +27,7 @@ FIPNUM
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
self.deck = sunbeam.deck.parse_string(self.DECK_STRING)
|
||||
self.deck = opm.deck.parse_string(self.DECK_STRING)
|
||||
|
||||
def test_deck_in(self):
|
||||
map(lambda kw: self.assertIn(kw, self.deck), [
|
||||
@@ -49,7 +49,7 @@ FIPNUM
|
||||
str(self.deck['DX']).split()
|
||||
)
|
||||
self.assertEqual(
|
||||
str(sunbeam.deck.parse_string('RUNSPEC\n\nDX\n4*0.5 /')).split(),
|
||||
str(opm.deck.parse_string('RUNSPEC\n\nDX\n4*0.5 /')).split(),
|
||||
'RUNSPEC DX 0.5 0.5 0.5 0.5 /'.split()
|
||||
)
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import sunbeam
|
||||
import opm
|
||||
|
||||
class TestGroupTree(unittest.TestCase):
|
||||
def setUp(self):
|
||||
norne = 'examples/data/norne/NORNE_ATW2013.DATA'
|
||||
self.sch = sunbeam.parse(norne, [('PARSE_RANDOM_SLASH', sunbeam.action.ignore)]).schedule
|
||||
self.sch = opm.parse(norne, [('PARSE_RANDOM_SLASH', opm.action.ignore)]).schedule
|
||||
|
||||
def test_group(self):
|
||||
gr = self.sch.group(timestep=2)['PROD']
|
||||
@@ -35,7 +35,7 @@ class TestGroupTree(unittest.TestCase):
|
||||
group = self.sch.group(timestep=3)['PROD']
|
||||
children = ['MANI-B1', 'MANI-B2', 'MANI-D1', 'MANI-D2', 'MANI-E1', 'MANI-E2']
|
||||
names = [child.name for child in group.children]
|
||||
self.assertEqual(sunbeam.schedule.Group, type(child))
|
||||
self.assertEqual(opm.schedule.Group, type(child))
|
||||
self.assertEqual(set(children), set(names))
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
import sunbeam
|
||||
import opm
|
||||
|
||||
class TestGrupnet(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
norne = 'examples/data/norne/NORNE_ATW2013.DATA'
|
||||
cls.sch = sunbeam.parse(norne, [('PARSE_RANDOM_SLASH', sunbeam.action.ignore)]).schedule
|
||||
cls.sch = opm.parse(norne, [('PARSE_RANDOM_SLASH', opm.action.ignore)]).schedule
|
||||
|
||||
def test_vfp_table(self):
|
||||
self.assertEqual(0, self.sch.group(timestep=0)['PROD'].vfp_table_nr)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import unittest
|
||||
import sunbeam
|
||||
import opm
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
@@ -33,36 +33,36 @@ FIPNUM
|
||||
self.norne_fname = os.path.abspath('examples/data/norne/NORNE_ATW2013.DATA')
|
||||
|
||||
def test_parse(self):
|
||||
spe3 = sunbeam.parse(self.spe3fn)
|
||||
spe3 = opm.parse(self.spe3fn)
|
||||
self.assertEqual('SPE 3 - CASE 1', spe3.state.title)
|
||||
|
||||
def test_parse_with_recovery(self):
|
||||
recovery = [("PARSE_RANDOM_SLASH", sunbeam.action.ignore)]
|
||||
spe3 = sunbeam.parse(self.spe3fn, recovery=recovery)
|
||||
recovery = [("PARSE_RANDOM_SLASH", opm.action.ignore)]
|
||||
spe3 = opm.parse(self.spe3fn, recovery=recovery)
|
||||
|
||||
def test_parse_with_multiple_recoveries(self):
|
||||
recoveries = [ ("PARSE_RANDOM_SLASH", sunbeam.action.ignore),
|
||||
("FOO", sunbeam.action.warn),
|
||||
("PARSE_RANDOM_TEXT", sunbeam.action.throw) ]
|
||||
recoveries = [ ("PARSE_RANDOM_SLASH", opm.action.ignore),
|
||||
("FOO", opm.action.warn),
|
||||
("PARSE_RANDOM_TEXT", opm.action.throw) ]
|
||||
|
||||
spe3 = sunbeam.parse(self.spe3fn, recovery=recoveries)
|
||||
spe3 = opm.parse(self.spe3fn, recovery=recoveries)
|
||||
|
||||
def test_throw_on_invalid_recovery(self):
|
||||
recoveries = [ ("PARSE_RANDOM_SLASH", 3.14 ) ]
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
sunbeam.parse(self.spe3fn, recovery=recoveries)
|
||||
opm.parse(self.spe3fn, recovery=recoveries)
|
||||
|
||||
with self.assertRaises(TypeError):
|
||||
sunbeam.parse(self.spe3fn, recovery="PARSE_RANDOM_SLASH")
|
||||
opm.parse(self.spe3fn, recovery="PARSE_RANDOM_SLASH")
|
||||
|
||||
def test_data(self):
|
||||
pass
|
||||
#regtest = sunbeam.parse(self.REGIONDATA)
|
||||
#regtest = opm.parse(self.REGIONDATA)
|
||||
#self.assertEqual([3,3,1,2], regtest.props()['OPERNUM'])
|
||||
|
||||
def test_parse_norne(self):
|
||||
state = sunbeam.parse(self.norne_fname, recovery=[('PARSE_RANDOM_SLASH', sunbeam.action.ignore)])
|
||||
state = opm.parse(self.norne_fname, recovery=[('PARSE_RANDOM_SLASH', opm.action.ignore)])
|
||||
es = state.state
|
||||
self.assertEqual(46, es.grid().getNX())
|
||||
self.assertEqual(112, es.grid().getNY())
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import unittest
|
||||
import sunbeam
|
||||
import sunbeam.deck
|
||||
import opm
|
||||
import opm.deck
|
||||
import os.path
|
||||
|
||||
class TestParse(unittest.TestCase):
|
||||
@@ -55,22 +55,22 @@ FIPNUM
|
||||
|
||||
def test_IOError(self):
|
||||
with self.assertRaises(IOError):
|
||||
sunbeam.parse("file/not/found")
|
||||
opm.parse("file/not/found")
|
||||
|
||||
with self.assertRaises(IOError):
|
||||
sunbeam.deck.parse("/file/not/found")
|
||||
opm.deck.parse("/file/not/found")
|
||||
|
||||
|
||||
|
||||
def test_parser_fail_without_extension(self):
|
||||
error_recovery = [("PARSE_RANDOM_SLASH", sunbeam.action.ignore)]
|
||||
error_recovery = [("PARSE_RANDOM_SLASH", opm.action.ignore)]
|
||||
with self.assertRaises(ValueError):
|
||||
sunbeam.deck.parse_string(self.DECK_ADDITIONAL_KEYWORDS,
|
||||
opm.deck.parse_string(self.DECK_ADDITIONAL_KEYWORDS,
|
||||
recovery=error_recovery )
|
||||
|
||||
def test_parser_extension(self):
|
||||
error_recovery = [("PARSE_RANDOM_SLASH", sunbeam.action.ignore)]
|
||||
deck = sunbeam.deck.parse_string(self.DECK_ADDITIONAL_KEYWORDS,
|
||||
error_recovery = [("PARSE_RANDOM_SLASH", opm.action.ignore)]
|
||||
deck = opm.deck.parse_string(self.DECK_ADDITIONAL_KEYWORDS,
|
||||
keywords=self.KEYWORDS,
|
||||
recovery=error_recovery )
|
||||
self.assertIn( 'TESTKEY0', deck )
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import unittest
|
||||
import sunbeam
|
||||
import opm
|
||||
|
||||
class TestProps(unittest.TestCase):
|
||||
|
||||
@@ -9,7 +9,7 @@ class TestProps(unittest.TestCase):
|
||||
self.assertTrue(diff <= epsilon, msg=err_msg)
|
||||
|
||||
def setUp(self):
|
||||
self.spe3 = sunbeam.parse('tests/spe3/SPE3CASE1.DATA').state
|
||||
self.spe3 = opm.parse('tests/spe3/SPE3CASE1.DATA').state
|
||||
self.props = self.spe3.props()
|
||||
|
||||
def test_repr(self):
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import unittest
|
||||
import datetime as dt
|
||||
import sunbeam
|
||||
import opm
|
||||
|
||||
|
||||
class TestSchedule(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.sch = sunbeam.parse('tests/spe3/SPE3CASE1.DATA').schedule
|
||||
cls.sch = opm.parse('tests/spe3/SPE3CASE1.DATA').schedule
|
||||
|
||||
def testWells(self):
|
||||
self.assertEqual(2, len(self.sch.get_wells(0)))
|
||||
@@ -36,8 +36,8 @@ class TestSchedule(unittest.TestCase):
|
||||
|
||||
def head(xs): return next(iter(xs))
|
||||
|
||||
inje = head(filter(sunbeam.Well.injector(), g1))
|
||||
prod = head(filter(sunbeam.Well.producer(), g1))
|
||||
inje = head(filter(opm.Well.injector(), g1))
|
||||
prod = head(filter(opm.Well.producer(), g1))
|
||||
|
||||
self.assertEqual(self.sch.get_well('INJ', 0).isinjector(), inje.isinjector())
|
||||
self.assertEqual(self.sch.get_well('PROD', 0).isproducer(), prod.isproducer())
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import unittest
|
||||
import sunbeam
|
||||
import opm
|
||||
|
||||
class TestState(unittest.TestCase):
|
||||
FAULTS_DECK = """
|
||||
@@ -49,8 +49,8 @@ SATNUM
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.spe3 = sunbeam.parse('tests/spe3/SPE3CASE1.DATA')
|
||||
cpa = sunbeam.parse('tests/data/CORNERPOINT_ACTNUM.DATA')
|
||||
cls.spe3 = opm.parse('tests/spe3/SPE3CASE1.DATA')
|
||||
cpa = opm.parse('tests/data/CORNERPOINT_ACTNUM.DATA')
|
||||
cls.state = cls.spe3.state
|
||||
cls.cp_state = cpa.state
|
||||
|
||||
@@ -124,7 +124,7 @@ SATNUM
|
||||
def test_faults(self):
|
||||
self.assertEquals([], self.state.faultNames())
|
||||
self.assertEquals({}, self.state.faults())
|
||||
faultdeck = sunbeam.parse_string(self.FAULTS_DECK).state
|
||||
faultdeck = opm.parse_string(self.FAULTS_DECK).state
|
||||
self.assertEqual(['F1', 'F2'], faultdeck.faultNames())
|
||||
# 'F2' 5 5 1 4 1 4 'X-' / \n"
|
||||
f2 = faultdeck.faultFaces('F2')
|
||||
@@ -139,7 +139,7 @@ SATNUM
|
||||
# jf["OIL_WATER"] = 21.0 # set in deck
|
||||
# jf["GAS_OIL"] = -1.0 # N/A
|
||||
|
||||
js = sunbeam.parse('tests/data/JFUNC.DATA').state
|
||||
js = opm.parse('tests/data/JFUNC.DATA').state
|
||||
self.assertEqual('JFUNC TEST', js.title)
|
||||
jf = js.jfunc()
|
||||
print(jf)
|
||||
@@ -167,7 +167,7 @@ JFUNC
|
||||
GAS * 13.0 0.6 0.7 Z /
|
||||
PROPS\nREGIONS
|
||||
"""
|
||||
js_gas = sunbeam.parse_string(jfunc_gas).state
|
||||
js_gas = opm.parse_string(jfunc_gas).state
|
||||
jf = js_gas.jfunc()
|
||||
self.assertEqual(jf['FLAG'], 'GAS')
|
||||
self.assertEqual(jf['DIRECTION'], 'Z')
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import unittest
|
||||
import datetime
|
||||
from sunbeam.tools import *
|
||||
import sunbeam.deck
|
||||
from opm.tools import *
|
||||
import opm.deck
|
||||
|
||||
from utils import tmp
|
||||
class TestTimeVector(unittest.TestCase):
|
||||
@@ -120,7 +120,7 @@ class TestTimeVector(unittest.TestCase):
|
||||
def test_no_leading_DATES(self):
|
||||
tv = TimeVector(datetime.date(1997, 11, 6), base_file="tests/data/schedule/part1.sch")
|
||||
s = str(tv)
|
||||
d = sunbeam.deck.parse_string(s)
|
||||
d = opm.deck.parse_string(s)
|
||||
kw0 = d[0]
|
||||
self.assertEqual(kw0.name, "WELSPECS")
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import unittest
|
||||
import sunbeam
|
||||
import opm
|
||||
|
||||
class TestWells(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.sch = sunbeam.parse('tests/spe3/SPE3CASE1.DATA').schedule
|
||||
cls.sch = opm.parse('tests/spe3/SPE3CASE1.DATA').schedule
|
||||
cls.timesteps = cls.sch.timesteps
|
||||
# cls.wells = cls.sch.wells
|
||||
|
||||
def inje(self, wells):
|
||||
return next(iter(filter(sunbeam.Well.injector(), wells)))
|
||||
return next(iter(filter(opm.Well.injector(), wells)))
|
||||
|
||||
def prod(self, wells):
|
||||
return next(iter(filter(sunbeam.Well.producer(), wells)))
|
||||
return next(iter(filter(opm.Well.producer(), wells)))
|
||||
|
||||
def testWellPos0(self):
|
||||
wells = self.sch.get_wells(0)
|
||||
@@ -63,14 +63,14 @@ class TestWells(unittest.TestCase):
|
||||
self.assertTrue(prod.available_gctrl())
|
||||
|
||||
def testWellDefinedFilter(self):
|
||||
defined0 = list(filter(sunbeam.Well.defined(0), self.sch.get_wells(0) ))
|
||||
defined1 = list(filter(sunbeam.Well.defined(1), self.sch.get_wells(1) ))
|
||||
defined0 = list(filter(opm.Well.defined(0), self.sch.get_wells(0) ))
|
||||
defined1 = list(filter(opm.Well.defined(1), self.sch.get_wells(1) ))
|
||||
self.assertEqual(len(list(defined0)), 2)
|
||||
self.assertEqual(len(list(defined1)), 2)
|
||||
|
||||
def testWellProdInjeFilter(self):
|
||||
inje = list(filter(sunbeam.Well.injector(), self.sch.get_wells(0) ))
|
||||
prod = list(filter(sunbeam.Well.producer(), self.sch.get_wells(0) ))
|
||||
inje = list(filter(opm.Well.injector(), self.sch.get_wells(0) ))
|
||||
prod = list(filter(opm.Well.producer(), self.sch.get_wells(0) ))
|
||||
|
||||
self.assertEqual(len(inje), 1)
|
||||
self.assertEqual(len(prod), 1)
|
||||
@@ -81,15 +81,15 @@ class TestWells(unittest.TestCase):
|
||||
def testOpenFilter(self):
|
||||
wells = self.sch.get_wells(1)
|
||||
|
||||
open_at_1 = sunbeam.Well.flowing()
|
||||
open_at_1 = opm.Well.flowing()
|
||||
flowing = list(filter(open_at_1, wells))
|
||||
closed = list(filter(lambda well: not open_at_1(well), wells))
|
||||
|
||||
self.assertEqual(2, len(flowing))
|
||||
self.assertEqual(0, len(closed))
|
||||
|
||||
flowing1 = filter(lambda x: not sunbeam.Well.closed()(x), wells)
|
||||
closed1 = filter(sunbeam.Well.closed(), wells)
|
||||
flowing1 = filter(lambda x: not opm.Well.closed()(x), wells)
|
||||
closed1 = filter(opm.Well.closed(), wells)
|
||||
self.assertListEqual(list(closed), list(closed1))
|
||||
|
||||
def testCompletions(self):
|
||||
|
||||
Reference in New Issue
Block a user