Skip to content

Commit

Permalink
Remove dependencies and refactor test code and data (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrivenaes authored Nov 17, 2021
1 parent dca29f1 commit a195124
Show file tree
Hide file tree
Showing 55 changed files with 1,488 additions and 588 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@ python:
os:
- linux


if: (branch =~ /^dev/) OR (repo == equinor/xtgeoapp-grd3dmaps)

before_script:
- pip install -U pip
- pip install black && black --check *.py src tests/test*.py docs/*.py || echo
- pip install flake8
- flake8 src tests docs
- git clone https://github.com/equinor/xtgeo-testdata.git ../xtgeo-testdata


script:
- pip install -r requirements.txt
Expand Down
14 changes: 7 additions & 7 deletions docs/config-hc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ The following example shows input from Eclipse where a Eclipse root name must ex
.. code-block:: yaml
input:
eclroot: ../xtgeo-testdata/3dgrids/reek/REEK
eclroot: tests/data/reek/REEK
dates:
- 19991201
- 20021101
Expand All @@ -78,8 +78,8 @@ It is possible to use a grid spsfication from a ROFF file instead of an EGRID fi
.. code-block:: yaml
input:
eclroot: ../xtgeo-testdata/3dgrids/reek/REEK
grid: ../xtgeo-testdata/3dgrids/reek/reek_grid_fromegrid.roff
eclroot: tests/data/reek/REEK
grid: tests/data/reek/reek_grid_fromegrid.roff
dates:
- 19991201
Expand All @@ -94,8 +94,8 @@ to make HC thickness maps from geomodels directly.
.. code-block:: yaml
input:
grid: ../xtgeo-testdata/3dgrids/reek/reek_geo_grid.roff
stoiip: {STOIIP: ../xtgeo-testdata/3dgrids/reek/reek_geo_stooip.roff}
grid: tests/data/reek/reek_geo_grid.roff
stoiip: {STOIIP: tests/data/reek/reek_geo_stooip.roff}
dates: [19900101]
The "STOIIP" in the example above is the name of the property within the ROFF file.
Expand All @@ -113,7 +113,7 @@ Dates can now be read directly from an external global-variables YAML file:
.. code-block:: yaml
input:
eclroot: ../xtgeo-testdata/3dgrids/reek/REEK
eclroot: tests/data/reek/REEK
dates: !include_from tests/yaml/global_config3a.yml::global.DATES
diffdates: !include_from tests/yaml/global_config3a.yml::global.DIFFDATES
Expand All @@ -134,7 +134,7 @@ properties, either continuous of discrete. For example:
-
name: FACIES
discrete: Yes
source: ../xtgeo-testdata/3dgrids/reek/reek_sim_facies2.roff
source: tests/data/reek/reek_sim_facies2.roff
discrange: [1] # Filter for a discrete will be spesic number (code)
Expand Down
2 changes: 1 addition & 1 deletion docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ file, e.g. as:
.. code-block:: yaml
input:
eclroot: ../xtgeo-testdata/3dgrids/reek/REEK
eclroot: tests/data/reek/REEK
dates: !include_from ../../share/fmuconfig/output/global_variables.yml::global.DATES
diffdates: !include_from ../../share/fmuconfig/output/global_variables.yml::global.DIFFDATES
Expand Down
8 changes: 3 additions & 5 deletions src/xtgeoapp_grd3dmaps/avghc/_compute_avg.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import getpass
from time import localtime, strftime
from collections import OrderedDict
from time import localtime, strftime

import numpy as np
import numpy.ma as ma

import xtgeo
from xtgeo.common import XTGeoDialog
from xtgeo.surface import RegularSurface

from xtgeoviz import quickplot

xtg = XTGeoDialog()
Expand Down Expand Up @@ -120,13 +119,12 @@ def do_avg_plotting(config, avgd):

pcfg = _avg_plotsettings(config, zname, pname)

xtg.say("Plot to {}".format(plotfile))
xtg.say(f"Plot to {plotfile}")

usevrange = pcfg["valuerange"]

faults = None
if pcfg["faultpolygons"] is not None:
xtg.say("Try: {}".format(pcfg["faultpolygons"]))
try:
fau = xtgeo.polygons_from_file(pcfg["faultpolygons"], fformat="guess")
faults = {"faults": fau}
Expand Down
31 changes: 31 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""Conftest.py pytest setup."""
import os
import shutil

import pytest


@pytest.fixture(name="datatree", scope="session", autouse=True)
def fixture_datatree(tmp_path_factory):
"""Create a tmp folder structure for testing."""
tmppath = tmp_path_factory.mktemp("grd3dmaps")

shutil.copytree("tests/yaml", tmppath / "tests" / "yaml")
shutil.copytree("tests/data", tmppath / "tests" / "data")

print("Temporary folder: ", tmppath)
os.chdir(tmppath)
return tmppath


@pytest.fixture(name="erttree", scope="session", autouse=True)
def fixture_erttree(tmp_path_factory):
"""Create a tmp folder structure for testing ert connection."""
tmppath = tmp_path_factory.mktemp("ertrun")

shutil.copytree("tests/yaml", tmppath / "tests" / "yaml")
shutil.copytree("tests/data", tmppath / "tests" / "data")

print("Temporary folder: ", tmppath)
os.chdir(tmppath)
return tmppath
Binary file added tests/data/reek/REEK.EGRID
Binary file not shown.
Binary file added tests/data/reek/REEK.INIT
Binary file not shown.
Binary file added tests/data/reek/REEK.UNRST
Binary file not shown.
Binary file not shown.
Binary file added tests/data/reek/reek2_grid_w_zerolayer.roff
Binary file not shown.
Binary file added tests/data/reek/reek2_grid_w_zerolayer_dz.roff
Binary file not shown.
Binary file added tests/data/reek/reek_geo_grid.roff
Binary file not shown.
Binary file added tests/data/reek/reek_geo_stooip.roff
Binary file not shown.
Binary file added tests/data/reek/reek_grid_fromegrid.roff
Binary file not shown.
Binary file added tests/data/reek/reek_hcmap_rotated.gri
Binary file not shown.
Binary file added tests/data/reek/reek_sim_facies2.roff
Binary file not shown.
Binary file added tests/data/reek/reek_sim_grid.roff
Binary file not shown.
Binary file added tests/data/reek/reek_sim_permx.roff
Binary file not shown.
Binary file added tests/data/reek/reek_sim_poro.roff
Binary file not shown.
Binary file added tests/data/reek/reek_sim_zone.roff
Binary file not shown.
Loading

0 comments on commit a195124

Please sign in to comment.