Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full Integration Tests #295

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tests/cooling/cooling_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
import json
import numpy as np
import os

# author: Jalal Lakhlili

Expand Down Expand Up @@ -44,3 +45,6 @@ def f(T, time, kappa, T_env):
np.savetxt(output_filename, te,
delimiter=",", comments='',
header='te')
# output json file
with open(os.path.splitext(output_filename)[0] + '.json', 'wt') as fd:
json.dump({'te': list(te)}, fd)
70 changes: 70 additions & 0 deletions tests/test_full.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import easyvvuq as uq
import chaospy as cp
import os

Check notice

Code scanning / CodeQL

Unused import Note test

Import of 'os' is not used.
import sys

Check notice

Code scanning / CodeQL

Unused import Note test

Import of 'sys' is not used.
import pytest
import itertools
import tempfile

@pytest.mark.parametrize(
'encoder,decoder,sampler_analysis',
itertools.product(
[uq.encoders.GenericEncoder(
template_fname='tests/cooling/cooling.template',
delimiter='$',
target_filename='cooling_in.json')],
[uq.decoders.SimpleCSV(
target_filename='output.csv',
output_columns=['te']),
uq.decoders.JSONDecoder(
target_filename='output.json',
output_columns=['te'])],
[(uq.sampling.PCESampler, uq.analysis.PCEAnalysis),
(uq.sampling.SCSampler, uq.analysis.SCAnalysis),
(lambda vary: uq.sampling.QMCSampler(vary, 25), uq.analysis.QMCAnalysis)]))
def test_full_campaign(encoder, decoder, sampler_analysis):
with tempfile.TemporaryDirectory() as tmp_path:
params = {
"temp_init": {
"type": "float",
"min": 0.0,
"max": 100.0,
"default": 95.0},
"kappa": {
"type": "float",
"min": 0.0,
"max": 0.1,
"default": 0.025},
"t_env": {
"type": "float",
"min": 0.0,
"max": 40.0,
"default": 15.0},
"out_file": {
"type": "string",
"default": "output.csv"
}
}
vary = {
"kappa": cp.Uniform(0.025, 0.075),
"t_env": cp.Uniform(15, 25)
}
sampler, analysis = sampler_analysis
sampler = sampler(vary)
analysis = analysis(sampler, qoi_cols=['te'])
actions = uq.actions.ExecuteLocal("tests/cooling/cooling_model.py cooling_in.json")
campaign = uq.Campaign(
name='test_campaign', work_dir=tmp_path, db_location='sqlite:///:memory:')
campaign.add_app(name='test_app',
params=params,
encoder=encoder,
decoder=decoder)
Comment on lines +58 to +61

Check failure

Code scanning / CodeQL

Wrong name for an argument in a call Error test

Keyword argument 'encoder' is not a supported parameter name of
method Campaign.add_app
.
Keyword argument 'decoder' is not a supported parameter name of
method Campaign.add_app
.
campaign.set_app('test_app')
campaign.set_sampler(sampler)
campaign.draw_samples()
campaign.populate_runs_dir()
campaign.apply_for_each_run_dir(actions)
campaign.collate()
df = campaign.get_collation_result()
result = analysis.analyse(df)

Check notice

Code scanning / CodeQL

Unused local variable Note test

Variable result is not used.

Loading