-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest_ravenpy.py
More file actions
48 lines (32 loc) · 1.48 KB
/
test_ravenpy.py
File metadata and controls
48 lines (32 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import pathlib
from importlib.util import find_spec
from ravenpy import Emulator, EnsembleReader
def test_ensemble_reader(gr4jcn_config, tmp_path):
"""Mimics code in docs/outputs.md"""
conf, params = gr4jcn_config
params = [params, params]
# Output directory for all simulations
p = tmp_path / "ensemble"
# Writing to the same custom output cause segfaults
# conf.custom_output = [rc.CustomOutput(time_per="DAILY", stat="AVERAGE", variable="RAINFALL",
# space_agg="ENTIRE_WATERSHED")]
# Run the model for each parameter set in `params`
runs = [Emulator(conf.set_params(param), workdir=p / f"m{i}").run() for i, param in enumerate(params)]
ens = EnsembleReader(runs=runs, dim="parameters")
assert len(ens.hydrograph.parameters) == 2
# Create a list of output paths using glob
paths = p.glob("**/output")
ens = EnsembleReader(paths=paths, dim="parameters")
assert len(ens.hydrograph.parameters) == 2
def test_package_metadata():
"""Test the package metadata."""
project = find_spec("ravenpy")
assert project is not None
assert project.submodule_search_locations is not None
location = project.submodule_search_locations[0]
metadata = pathlib.Path(location).resolve().joinpath("__init__.py")
with metadata.open() as f:
contents = f.read()
assert """David Huard""" in contents
assert '__email__ = "huard.david@ouranos.ca"' in contents
assert '__version__ = "0.19.1"' in contents