add python 3 support and travis test

This commit is contained in:
Kristian Reed
2018-02-15 13:25:31 +01:00
parent 4f26da6e20
commit 491c1461f2
9 changed files with 43 additions and 26 deletions

View File

@@ -1,6 +1,5 @@
language: cpp
language: python
dist: trusty
sudo: false
compiler:
- gcc
@@ -10,7 +9,6 @@ os:
env:
global:
- PYENV_VERSION=2.7
- INSTALL_ROOT=$HOME/install
addons:
@@ -20,10 +18,17 @@ addons:
- ubuntu-toolchain-r-test
packages:
- libboost1.55-all-dev
- gcc-4.8
- g++-4.8
- liblapack-dev
sudo: required
python:
- 2.7
- 3.6
matrix:
fast_finish: true
install:
- pushd ..
@@ -37,18 +42,23 @@ install:
- mkdir opm-parser/build
- pushd opm-parser/build
- git checkout release/2017.10/final
- cmake -DCMAKE_PREFIX_PATH=$INSTALL_ROOT -DCMAKE_INSTALL_PREFIX=$INSTALL_ROOT -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=ON ..
- cmake .. -DCMAKE_PREFIX_PATH=$INSTALL_ROOT
-DCMAKE_INSTALL_PREFIX=$INSTALL_ROOT
-DBUILD_TESTING=OFF
-DBUILD_SHARED_LIBS=ON
- make install
- popd
- popd
- pip install --user -r requirements.txt
- pip install -r requirements.txt
script:
- mkdir build
- pushd build
- cmake -DCMAKE_PREFIX_PATH=$INSTALL_ROOT -DUSE_RPATH=ON -DCMAKE_INSTALL_PREFIX=$INSTALL_ROOT ..
- cmake .. -DCMAKE_PREFIX_PATH=$INSTALL_ROOT
-DUSE_RPATH=ON
-DCMAKE_INSTALL_PREFIX=$INSTALL_ROOT
-DPYTHON_EXECUTABLE=`which python`
- make install
- export PYTHONPATH=$PYTHONPATH:$INSTALL_ROOT/lib/python${PYENV_VERSION}/site-packages
- ctest --output-on-failure
- popd

View File

@@ -5,7 +5,7 @@ include( CheckCXXSourceCompiles )
include( CTest )
find_package(opm-parser REQUIRED)
find_package(PythonInterp 2.7 REQUIRED)
find_package(PythonInterp REQUIRED)
set( warnings "-Wall -Wextra -pedantic -Wpointer-arith" )
set( warnings "${warnings} -Wformat-nonliteral -Wcast-align" )

View File

@@ -1,11 +1,10 @@
"""
"""
from __future__ import absolute_import
from .schedule import Well, Completion
from .libsunbeam import action
from .config import EclipseConfig
from .parser import parse_deck, parse
__version__ = '0.0.4'
__license__ = 'GNU General Public License version 3'

View File

@@ -1,5 +1,6 @@
from os.path import isfile
import libsunbeam as lib
from __future__ import absolute_import
from sunbeam import libsunbeam as lib
from .sunbeam import delegate
@delegate(lib.SummaryConfig)

View File

@@ -1,6 +1,8 @@
from __future__ import absolute_import
from os.path import isfile
import json
import libsunbeam as lib
from sunbeam import libsunbeam as lib
from .properties import EclipseState
@@ -108,7 +110,7 @@ def parse_deck(deck, keywords=[], recovery=[]):
# carry on
if isinstance(keywords, dict):
keywords = [keywords]
keywords = map(json.dumps, keywords)
keywords = list(map(json.dumps, keywords))
is_file = isfile(deck) # If the deck is a file, the deck is read from
# that file. Otherwise it is assumed to be a
# string representation of the the deck.

View File

@@ -1,5 +1,7 @@
from __future__ import absolute_import
from os.path import isfile
import libsunbeam as lib
from sunbeam import libsunbeam as lib
from .sunbeam import delegate
from .schedule import Schedule
from .config import EclipseConfig

View File

@@ -1,4 +1,6 @@
import libsunbeam as lib
from __future__ import absolute_import
from sunbeam import libsunbeam as lib
from .sunbeam import delegate
@delegate(lib.Schedule)
@@ -11,7 +13,7 @@ class Schedule(object):
@property
def wells(self):
return map(Well, self._wells)
return list(map(Well, self._wells))
def group(self, timestep=0):
return {grp.name: grp for grp in self.groups(timestep)}
@@ -35,7 +37,7 @@ class Well(object):
return 'Well(name = "%s")' % self.name
def completions(self, timestep):
return map(Completion, self._completions(timestep))
return list(map(Completion, self._completions(timestep)))
def __eq__(self,other):
return self._sun.__equal__(other._sun)

View File

@@ -1,4 +1,5 @@
import libsunbeam as lib
from __future__ import absolute_import
class _delegate(object):
def __init__(self, name, attr):
@@ -26,13 +27,13 @@ def delegate(delegate_cls, to = '_sun'):
pass
setattr(cls, to, _property())
for attr in attributes - set(cls.__dict__.keys() + ['__init__']):
for attr in attributes - set(list(cls.__dict__.keys()) + ['__init__']):
setattr(cls, attr, _delegate(to, attr))
src, dst = getattr(delegate_cls, attr), getattr(cls, attr)
setattr(dst, '__doc__', src.__doc__)
def new__new__(_cls, this, *args, **kwargs):
new = super(cls, _cls).__new__(_cls, *args, **kwargs)
new = super(cls, _cls).__new__(_cls)
setattr(new, to, this) # self._sun = this
return new

View File

@@ -29,8 +29,8 @@ class TestWells(unittest.TestCase):
flowing = sunbeam.Completion.flowing()
closed = sunbeam.Completion.closed()
completions = self.wells[0].completions(0)
self.assertEqual(len(filter(flowing, completions)), 2)
self.assertEqual(len(filter(closed, completions)), 0)
self.assertEqual(len(list(filter(flowing, completions))), 2)
self.assertEqual(len(list(filter(closed, completions))), 0)
def test_direction(self):
for well in self.wells: