Skip to content

Commit

Permalink
unittest coverage (#95)
Browse files Browse the repository at this point in the history
* remove `__init__.py` from test directory

* first draft of example test

* test generated `fort.15` files against reference

* Fix code style issues with oitnb

* update examples

* fix directories

* update reference files

* reduce to only testing `example_3.py`

* Update best_track.py (#106)

optional annotation of track times.

* fix infinity comparison with string

* only accept path

* some summary stats of `BestTrack` (#107)

* A summary stats method for `BestTrack` 

* Set start and end dates automatically in the case of tides + wind forcing.

Co-authored-by: Keith Roberts <[email protected]>
Co-authored-by: Lint Action <[email protected]>
Co-authored-by: Jaime R Calzada <[email protected]>

* add ADCIRC v55 ICS options (#109)

* add ADCIRC v55 ICS options

* fixed case where CRS has no coordinate operation

* replace `CPP` with `EQUIDISTANT_CYLINDRICAL`

* add ICS setter

* filter ICS input to valid ADCIRC values

* formatting

* update `BestTrackForcing` (#111)

* update `BestTrackForcing` with updates from @WPringle and @zacharyburnettnoaa done in `ensembleperturbation/tropicalcyclone/atcf.py`

* Fix code style issues with oitnb

* remove redundant functions

* prevent rechecking name validity if not storm ID is given

* fix direction and speed calculations

* get correct ATCF URL from archive if it is in the storm table

* remove unused imports

* set default file deck and mode

* copy previous record data if data does not exist

* use `BEST` and file deck B for best track type

* add back type hint

* use EPSG

* update property name

* update reference files

* rename `requested_record_type` to `record_type`

* handle Pint `Quantity`

* handle no internet

* update copy method to directly copy data

* set configuration on `.__init__()`

Co-authored-by: Lint Action <[email protected]>

* hash location columns to determine when to compute velocity

* test location hashing

* add tests for vortex file decks and reading from file with no internet

* add reference file

* use `.loc` for setting slice

* suppress `SettingWithCopyWarning` when instantiating `VortexForcing`

* build on Windows (#52)

* if installing on Windows, download precompiled binaries for GDAL and Fiona

* fix scope error

* use `python setup.py install` instead of `pip install .`

* remove Python 3.6 (scipy deprecation)

* separately versioned builds are not needed

* use sudo when installing libraries

* forgot the &&

* add libgeos to install

* add libgeos to install

* add OS conditions to dependency install

* use conditions for linux library install

* fix not error

* explicitly use ubuntu

* fix key hit

* remove gdal version pin

* install to conda if detected

* comma

* update windows build

* update dependencies

* update dependencies

* Fix code style issues with oitnb

* improvements to dependency installation in setup

* try subdependencies first

* check package in subdependencies on every interation

* use `subprocess.run()`

* use `shell=True`

* try `pip install` before `pipwin install`

Co-authored-by: Lint Action <[email protected]>

* install to `--user` in build

* addressing NFOVER with DEBUG_WARN_ELEV compiler directive (#115)

* addressing NFOVER with DEBUG_WARN_ELEV compiler directive

* Fix code style issues with oitnb

* Proposed changes to NFOVER handling.

* Fixed typo.

* Fixed type checking.

Co-authored-by: Keith Roberts <[email protected]>
Co-authored-by: Lint Action <[email protected]>
Co-authored-by: Jaime R Calzada <[email protected]>

* improvements to creating `VortexForcing` from file (#118)

* if the given file does not exist, raise `FileNotFoundError` if the string does not contain useful data

* store a filename in the `VortexForcing` object so that it can be recreated without access to internet

* read from filename if it exists

* optimize `.import_stations()`

* Fix bug where final hull multipolygon was not being aggregated correctly

* Improved interp of near-shore points for TPXO

* fixed fort.13 enumeration issue

* Fix code style issues with oitnb

* fix merge

* Fix code style issues with oitnb

* Renamed kwarg for import_nodal_attributes

* Fix code style issues with oitnb

* add type hints + reorder setters to be after properties + use native timedelta methods + fix stations parser + other minor changes (#120)

* use timedelta comparisons and division

* reorder setters + use type hints

* reorder setters + use type hints

* fix setter before getter

* Fix bug where final hull multipolygon was not being aggregated correctly

* Improved interp of near-shore points for TPXO

* fixed fort.13 enumeration issue

* Fix code style issues with oitnb

* fix merge

* Fix code style issues with oitnb

* Renamed kwarg for import_nodal_attributes

* Fix code style issues with oitnb

* Revert to previous stations parser, preseve precision of input values for outputs

* Fix code style issues with oitnb

* Make coastline plotting optional + disable on tests due to server blocking

* Fix code style issues with oitnb

* update the names the stations parser looks for to be `NSTAE`, `NSTAV`, `NSTAC`, and `NSTAM`

* add test for importing stations

* call `super().__init__()` in constructor

* enumerate station types

* Fix code style issues with oitnb

* minor streamlining

* turn of Windows tests

* possible fix for #116

Co-authored-by: jreniel <[email protected]>
Co-authored-by: Lint Action <[email protected]>

* Correcting WTIMINC line for vortex forcing (NWS = 8, 19, 20). (#128)

* moving WTIMINC for BestTrackForcing class into fort15.py so can use the coldstart time instead of vortex start time on WTIMINC line

* add type hint

* simplify if statement

* update reference files

Co-authored-by: zachary.burnett <[email protected]>

* Feature/wind swath (#126)

* adding method to compute wind swath polygon (34-kt, 50-kt or 64-kt isotach) for given best_track class

* adding alphashape logic to ensure output is always a single Polygon with relatively smooth edges

* adding option to set alpha to None to return the swath without alphashape operation, also adding some information

* formatting

* construct swath from individual convex hulls of pairs of mixed isotachs at neighboring times

* formatting

* split isotach retrieval into separate method

* remove `lru_cache` usage

* remove alphashape from dependencies

Co-authored-by: zachary.burnett <[email protected]>

* add equality operator to compare meshes and forcings (#129)

* add equality operator to compare meshes

* offload nodal equality to `Nodes` object

* add test

* add object checks

* equality of forcings

* add copy method for adcirc mesh

* check for equal boundaries

* test copy method

* check equality of nodal attributes

* check absolute of values because it is copied as negative

* flip values upon reading `fort.14` but not in `.to_dict()`

* flip values upon writing `fort.14`

* formatting

* fix writing function

* log warning instead of raising exception when file exists and `overwrite` is `False`

* log warning instead of raising exception when file exists and `overwrite` is `False` (2/2)

* log warning instead of raising exception when file exists and `overwrite` is `False` (3/2)

* reduce amount of times `VortexForcing` connects to the internet (#131)

* get storm ID from dataframe

* remove unecessary call to internet from storm ID setter

* update tests with new storm ID getter

* check by name if basin / number fails

* update calls to utilize new changes

* add input file

* update bare `except`

* only add new attribute if it doesn't already exist, also improve attribute equality check (#133)

* only add new attribute if it doesn't already exist

* improve equality check

* revamp grid handling and writing 2dm file + mesh hull calculation (#121)

* revamp grid handling and writing 2dm file

* log writing durations

* use `.to_string()` to write `grd`

* update reference files

* change print to logging

* fix instances of nodes usage

* fix dataframe call

* simplify multipolygon generation

* move polygons into interiors of others

* collect stray interiors of polygons

* simplify loop

* don't need to explicitly create multilinestring

* formatting

* formatting

* use new `Rings` object

* merge

* update equality

* update reference files

* catch socket block

* replace area estimation (with convex hull) with actual triangle area using S equation

* revert

* invert all values when writing

* use grd function

* get array

* only initialize rings of 3 or more

* revert

* fix accessor to pandas object

* use `isclose` to determine area

* update reference files

* use pandas index getter

* adding buffer command to make mesh envelope valid

* remove polgyon testing for stations for now

* Fix code style issues with oitnb

* implement hull checks if requested by user during station import

* add formatted logger that splits output between `stdout` and `stderr` (#132)

* add formatted logger that splits output between `stdout` and `stderr`

* formatting

* formatting

* Fix code style issues with oitnb

Co-authored-by: Lint Action <[email protected]>

* use new parameter in test

* add print to setup.py

* faster conda package check

* hotfix for start date retrieval

* use function to filter log output

* update reference files

* fix logger name

* import logging

* fix flake8 errors

* update badges

* update lead developer now that @jreniel has stepped back from active development

* move `VortexForcing` into `ModelForcings` (#139)

* move `VortexForcing` into `ModelForcings`

* order dependencies alphabetically

* import from `modelforcings`

* this was incorrect syntax, my bad

* move `validation` module to https://github.com/zacharyburnettNOAA/CoupledModelValidation/tree/main/coupledmodelvalidation (#140)

* import from `typing` instead of directly from `collections` (deprecated)

* remove `colored_traceback`

* generate documentation automatically with Sphinx (#141)

* remove submodule as it no longer exists

* first draft of Sphinx docs

* copy documentation from ADCIRCpy NOAA tech report

* add figures

* add references to TOC and also turn citations into footnotes

* name abstract

* use `coupledmodelvalidation` for `plot_fort61`

* `:python:` is not a valid directive

* add references to abstract, and fix references page to list all citations

* add docs badge and link to docs

Co-authored-by: zacharyburnett <[email protected]>

* reorder TOC

* fix logger

* formatting

* add PDF to build

* update acknowledgments.rst

* change `modelforcings` to `stormevents` (#142)

* change `modelforcings` to `stormevents`

* formatting

* update documentation

* update documentation

* test latest version of Python

* formatting

* support Python 3.6 build

* update to use new StormEvents API

* update to use new StormEvents NHC storm list sources

* formatting

* this TODO has been resolved by new code in `stormevents`

* test on python 3.9

* modernize dependency installation

* remove call to `importlib` for python 3.6

* remove dependency on `coupledmodelvalidation` (#143)

* update examples

* running `example_3.py` resulted in a recursion error

* Revert "running `example_3.py` resulted in a recursion error"

This reverts commit c136336.

* update reference files

* update reference files

* mkdir in tests

* mkdir in tests

* skip example tests that don't currently work

Co-authored-by: Lint Action <[email protected]>
Co-authored-by: Keith Roberts <[email protected]>
Co-authored-by: Keith Roberts <[email protected]>
Co-authored-by: Jaime R Calzada <[email protected]>
Co-authored-by: William Pringle <[email protected]>
Co-authored-by: zacharyburnett <[email protected]>
  • Loading branch information
7 people authored Jan 20, 2022
1 parent 63d8b45 commit a3ad291
Show file tree
Hide file tree
Showing 25 changed files with 42,543 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
examples/outputs
examples/output
examples/data
tests/data/input
tests/data/output
Expand Down
64 changes: 37 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,19 @@ import shutil
from adcircpy import AdcircMesh, AdcircRun, Tides
from adcircpy.utilities import download_mesh

MESH_URL = 'https://www.dropbox.com/s/1wk91r67cacf132/NetCDF_shinnecock_inlet.tar.bz2?dl=1'

DATA_DIRECTORY = Path(__file__).parent.absolute() / 'data'
INPUT_DIRECTORY = DATA_DIRECTORY / 'input' / 'NetCDF_Shinnecock_Inlet'
INPUT_DIRECTORY = DATA_DIRECTORY / 'input' / 'shinnecock'
OUTPUT_DIRECTORY = DATA_DIRECTORY / 'output' / 'example_1'

MESH_URL = 'https://www.dropbox.com/s/1wk91r67cacf132/NetCDF_shinnecock_inlet.tar.bz2?dl=1'
MESH_DIRECTORY = INPUT_DIRECTORY / 'shinnecock'

download_mesh(
url=MESH_URL, directory=INPUT_DIRECTORY,
url=MESH_URL, directory=MESH_DIRECTORY,
)

# open mesh file
mesh = AdcircMesh.open(INPUT_DIRECTORY / 'fort.14', crs=4326)
mesh = AdcircMesh.open(MESH_DIRECTORY / 'fort.14', crs=4326)

# initialize tidal forcing and constituents
tidal_forcing = Tides()
Expand Down Expand Up @@ -197,18 +198,19 @@ import numpy
from adcircpy import AdcircMesh, AdcircRun, Tides
from adcircpy.utilities import download_mesh

MESH_URL = 'https://www.dropbox.com/s/1wk91r67cacf132/NetCDF_shinnecock_inlet.tar.bz2?dl=1'

DATA_DIRECTORY = Path(__file__).parent.absolute() / 'data'
INPUT_DIRECTORY = DATA_DIRECTORY / 'input' / 'NetCDF_Shinnecock_Inlet'
INPUT_DIRECTORY = DATA_DIRECTORY / 'input'
OUTPUT_DIRECTORY = DATA_DIRECTORY / 'output' / 'example_2'

MESH_URL = 'https://www.dropbox.com/s/1wk91r67cacf132/NetCDF_shinnecock_inlet.tar.bz2?dl=1'
MESH_DIRECTORY = INPUT_DIRECTORY / 'shinnecock'

download_mesh(
url=MESH_URL, directory=INPUT_DIRECTORY,
url=MESH_URL, directory=MESH_DIRECTORY,
)

# open mesh file
mesh = AdcircMesh.open(INPUT_DIRECTORY / 'fort.14', crs=4326)
mesh = AdcircMesh.open(MESH_DIRECTORY / 'fort.14', crs=4326)

# generate tau0 factor
mesh.generate_tau0()
Expand Down Expand Up @@ -259,26 +261,27 @@ The following code is similar to `example_1.py`, above, except it adds HURDAT Be
job script for submission to a job manager.

```python
from datetime import timedelta
from datetime import datetime, timedelta
from pathlib import Path

from adcircpy import AdcircMesh, AdcircRun, Tides
from adcircpy.forcing.winds import BestTrackForcing
from adcircpy.server import SlurmConfig
from tests import download_mesh

MESH_URL = 'https://www.dropbox.com/s/1wk91r67cacf132/NetCDF_shinnecock_inlet.tar.bz2?dl=1'
from adcircpy.utilities import download_mesh

DATA_DIRECTORY = Path(__file__).parent.absolute() / 'data'
INPUT_DIRECTORY = DATA_DIRECTORY / 'input' / 'NetCDF_Shinnecock_Inlet'
OUTPUT_DIRECTORY = DATA_DIRECTORY / 'output' / 'example_3'
INPUT_DIRECTORY = DATA_DIRECTORY / 'input'
OUTPUT_DIRECTORY = DATA_DIRECTORY / 'output' / 'test_example_3'

MESH_URL = 'https://www.dropbox.com/s/1wk91r67cacf132/NetCDF_shinnecock_inlet.tar.bz2?dl=1'
MESH_DIRECTORY = INPUT_DIRECTORY / 'shinnecock'

download_mesh(
url=MESH_URL, directory=INPUT_DIRECTORY,
url=MESH_URL, directory=MESH_DIRECTORY,
)

# open mesh file
mesh = AdcircMesh.open(INPUT_DIRECTORY / 'fort.14', crs=4326)
mesh = AdcircMesh.open(MESH_DIRECTORY / 'fort.14', crs=4326)

# initialize tidal forcing and constituents
tidal_forcing = Tides()
Expand All @@ -293,18 +296,24 @@ mesh.add_forcing(wind_forcing)
slurm = SlurmConfig(
account='account',
ntasks=1000,
run_name='adcircpy/examples/example_3.py',
run_name='adcircpy/examples/test_example_3.py',
partition='partition',
walltime=timedelta(hours=8),
mail_type='all',
mail_user='[email protected]',
log_filename='example_3.log',
log_filename='test_example_3.log',
modules=['intel/2020', 'impi/2020', 'netcdf/4.7.2-parallel'],
path_prefix='$HOME/adcirc/build',
)

# set simulation dates
spinup_time = timedelta(days=15)
duration = timedelta(days=3)
start_date = datetime(2012, 10, 21, 18)
end_date = start_date + duration

# instantiate driver object
driver = AdcircRun(mesh, spinup_time=timedelta(days=15), server_config=slurm)
driver = AdcircRun(mesh, start_date, end_date, spinup_time, server_config=slurm)

# write driver state to disk
driver.write(OUTPUT_DIRECTORY, overwrite=True)
Expand All @@ -322,20 +331,21 @@ from adcircpy import AdcircMesh, AdcircRun, Tides
from adcircpy.forcing.waves.ww3 import WaveWatch3DataForcing
from adcircpy.forcing.winds.atmesh import AtmosphericMeshForcing
from adcircpy.server import SlurmConfig
from tests import download_mesh

MESH_URL = 'https://www.dropbox.com/s/1wk91r67cacf132/NetCDF_shinnecock_inlet.tar.bz2?dl=1'
from adcircpy.utilities import download_mesh

DATA_DIRECTORY = Path(__file__).parent.absolute() / 'data'
INPUT_DIRECTORY = DATA_DIRECTORY / 'input' / 'NetCDF_Shinnecock_Inlet'
INPUT_DIRECTORY = DATA_DIRECTORY / 'input'
OUTPUT_DIRECTORY = DATA_DIRECTORY / 'output' / 'example_4'

MESH_URL = 'https://www.dropbox.com/s/1wk91r67cacf132/NetCDF_shinnecock_inlet.tar.bz2?dl=1'
MESH_DIRECTORY = INPUT_DIRECTORY / 'shinnecock'

download_mesh(
url=MESH_URL, directory=INPUT_DIRECTORY,
url=MESH_URL, directory=MESH_DIRECTORY,
)

# open mesh file
mesh = AdcircMesh.open(INPUT_DIRECTORY / 'fort.14', crs=4326)
mesh = AdcircMesh.open(MESH_DIRECTORY / 'fort.14', crs=4326)

# initialize tidal forcing and constituents
tidal_forcing = Tides()
Expand Down
11 changes: 6 additions & 5 deletions examples/example_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@

LOGGER = get_logger(__name__)

MESH_URL = 'https://www.dropbox.com/s/1wk91r67cacf132/NetCDF_shinnecock_inlet.tar.bz2?dl=1'

DATA_DIRECTORY = Path(__file__).parent.absolute() / 'data'
INPUT_DIRECTORY = DATA_DIRECTORY / 'input' / 'NetCDF_Shinnecock_Inlet'
INPUT_DIRECTORY = DATA_DIRECTORY / 'input' / 'shinnecock'
OUTPUT_DIRECTORY = DATA_DIRECTORY / 'output' / 'example_1'

MESH_URL = 'https://www.dropbox.com/s/1wk91r67cacf132/NetCDF_shinnecock_inlet.tar.bz2?dl=1'
MESH_DIRECTORY = INPUT_DIRECTORY / 'shinnecock'

download_mesh(
url=MESH_URL, directory=INPUT_DIRECTORY,
url=MESH_URL, directory=MESH_DIRECTORY,
)

# open mesh file
mesh = AdcircMesh.open(INPUT_DIRECTORY / 'fort.14', crs=4326)
mesh = AdcircMesh.open(MESH_DIRECTORY / 'fort.14', crs=4326)

# initialize tidal forcing and constituents
tidal_forcing = Tides()
Expand Down
11 changes: 6 additions & 5 deletions examples/example_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@

LOGGER = get_logger(__name__)

MESH_URL = 'https://www.dropbox.com/s/1wk91r67cacf132/NetCDF_shinnecock_inlet.tar.bz2?dl=1'

DATA_DIRECTORY = Path(__file__).parent.absolute() / 'data'
INPUT_DIRECTORY = DATA_DIRECTORY / 'input' / 'NetCDF_Shinnecock_Inlet'
INPUT_DIRECTORY = DATA_DIRECTORY / 'input'
OUTPUT_DIRECTORY = DATA_DIRECTORY / 'output' / 'example_2'

MESH_URL = 'https://www.dropbox.com/s/1wk91r67cacf132/NetCDF_shinnecock_inlet.tar.bz2?dl=1'
MESH_DIRECTORY = INPUT_DIRECTORY / 'shinnecock'

download_mesh(
url=MESH_URL, directory=INPUT_DIRECTORY,
url=MESH_URL, directory=MESH_DIRECTORY,
)

# open mesh file
mesh = AdcircMesh.open(INPUT_DIRECTORY / 'fort.14', crs=4326)
mesh = AdcircMesh.open(MESH_DIRECTORY / 'fort.14', crs=4326)

# generate tau0 factor
mesh.generate_tau0()
Expand Down
21 changes: 14 additions & 7 deletions examples/example_3.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
from datetime import timedelta
from datetime import datetime, timedelta
from pathlib import Path

from adcircpy import AdcircMesh, AdcircRun, Tides
from adcircpy.forcing.winds import BestTrackForcing
from adcircpy.server import SlurmConfig
from adcircpy.utilities import download_mesh

MESH_URL = 'https://www.dropbox.com/s/1wk91r67cacf132/NetCDF_shinnecock_inlet.tar.bz2?dl=1'

DATA_DIRECTORY = Path(__file__).parent.absolute() / 'data'
INPUT_DIRECTORY = DATA_DIRECTORY / 'input' / 'NetCDF_Shinnecock_Inlet'
INPUT_DIRECTORY = DATA_DIRECTORY / 'input'
OUTPUT_DIRECTORY = DATA_DIRECTORY / 'output' / 'example_3'

MESH_URL = 'https://www.dropbox.com/s/1wk91r67cacf132/NetCDF_shinnecock_inlet.tar.bz2?dl=1'
MESH_DIRECTORY = INPUT_DIRECTORY / 'shinnecock'

download_mesh(
url=MESH_URL, directory=INPUT_DIRECTORY,
url=MESH_URL, directory=MESH_DIRECTORY,
)

# open mesh file
mesh = AdcircMesh.open(INPUT_DIRECTORY / 'fort.14', crs=4326)
mesh = AdcircMesh.open(MESH_DIRECTORY / 'fort.14', crs=4326)

# initialize tidal forcing and constituents
tidal_forcing = Tides()
Expand All @@ -42,8 +43,14 @@
path_prefix='$HOME/adcirc/build',
)

# set simulation dates
spinup_time = timedelta(days=15)
duration = timedelta(days=3)
start_date = datetime(2012, 10, 21, 18)
end_date = start_date + duration

# instantiate driver object
driver = AdcircRun(mesh, spinup_time=timedelta(days=15), server_config=slurm,)
driver = AdcircRun(mesh, start_date, end_date, spinup_time, server_config=slurm)

# write driver state to disk
driver.write(OUTPUT_DIRECTORY, overwrite=True)
11 changes: 6 additions & 5 deletions examples/example_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@
from adcircpy.server import SlurmConfig
from adcircpy.utilities import download_mesh

MESH_URL = 'https://www.dropbox.com/s/1wk91r67cacf132/NetCDF_shinnecock_inlet.tar.bz2?dl=1'

DATA_DIRECTORY = Path(__file__).parent.absolute() / 'data'
INPUT_DIRECTORY = DATA_DIRECTORY / 'input' / 'NetCDF_Shinnecock_Inlet'
INPUT_DIRECTORY = DATA_DIRECTORY / 'input'
OUTPUT_DIRECTORY = DATA_DIRECTORY / 'output' / 'example_4'

MESH_URL = 'https://www.dropbox.com/s/1wk91r67cacf132/NetCDF_shinnecock_inlet.tar.bz2?dl=1'
MESH_DIRECTORY = INPUT_DIRECTORY / 'shinnecock'

download_mesh(
url=MESH_URL, directory=INPUT_DIRECTORY,
url=MESH_URL, directory=MESH_DIRECTORY,
)

# open mesh file
mesh = AdcircMesh.open(INPUT_DIRECTORY / 'fort.14', crs=4326)
mesh = AdcircMesh.open(MESH_DIRECTORY / 'fort.14', crs=4326)

# initialize tidal forcing and constituents
tidal_forcing = Tides()
Expand Down
32 changes: 19 additions & 13 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from difflib import Differ
import os
from os import PathLike
from pathlib import Path
import re
from typing import Dict, List

from filelock import FileLock
import pytest
Expand All @@ -28,7 +29,9 @@ def shinnecock_mesh_directory(worker_id) -> Path:


def check_reference_directory(
test_directory: PathLike, reference_directory: PathLike, skip_lines: {str: [int]} = None
test_directory: PathLike,
reference_directory: PathLike,
skip_lines: Dict[str, List[int]] = None,
):
if not isinstance(test_directory, Path):
test_directory = Path(test_directory)
Expand All @@ -49,21 +52,24 @@ def check_reference_directory(
test_lines = list(test_file.readlines())
reference_lines = list(reference_file.readlines())

diff = '\n'.join(Differ().compare(test_lines, reference_lines))
message = f'"{test_filename}" != "{reference_filename}"\n{diff}'

assert len(test_lines) == len(reference_lines), message

lines_to_skip = set()
for file_mask, line_indices in skip_lines.items():
if file_mask in str(test_filename) or re.match(
file_mask, str(test_filename)
if (
file_mask in str(test_filename)
or re.match(file_mask, str(test_filename))
and len(test_lines) > 0
):
lines_to_skip.update(
line_index % len(test_lines) for line_index in line_indices
)
try:
lines_to_skip.update(
line_index % len(test_lines) for line_index in line_indices
)
except ZeroDivisionError:
continue

for line_index in sorted(lines_to_skip, reverse=True):
del test_lines[line_index], reference_lines[line_index]

assert '\n'.join(test_lines) == '\n'.join(reference_lines), message
cwd = Path.cwd()
assert '\n'.join(test_lines) == '\n'.join(
reference_lines
), f'"{os.path.relpath(test_filename, cwd)}" != "{os.path.relpath(reference_filename, cwd)}"'
35 changes: 35 additions & 0 deletions tests/data/reference/test_example_1/driver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

ulimit -s unlimited

set -e

NPROCS=4

main() {
rm -rf work
mkdir work
cd work
ln -sf ../fort.14
ln -sf ../fort.13
ln -sf ../fort.15 ./fort.15
adcprep --np 4 --partmesh
adcprep --np 4 --prepall
mpiexec -n 4 padcirc
clean_directory
cd ..
}

clean_directory() {
rm -rf PE*
rm -rf partmesh.txt
rm -rf metis_graph.txt
rm -rf fort.13
rm -rf fort.14
rm -rf fort.15
rm -rf fort.16
rm -rf fort.80
rm -rf fort.68.nc
}

main
Loading

0 comments on commit a3ad291

Please sign in to comment.