-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3077c0
commit 21382bd
Showing
3 changed files
with
68 additions
and
89 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env python | ||
|
||
import openturns as ot | ||
import otfmi | ||
import otfmi.example.deviation | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def path_fmu(): | ||
"""Load FMU and setup pure python reference.""" | ||
return otfmi.example.utility.get_path_fmu("epid") | ||
|
||
|
||
@pytest.fixture | ||
def mesh(): | ||
return ot.RegularGrid(2.0, 0.5, 50) | ||
|
||
|
||
def test_start_time_coherence(path_fmu, mesh): | ||
"""Check if incoherent start time raises an error""" | ||
with pytest.raises(AssertionError): | ||
_ = otfmi.FMUPointToFieldFunction(mesh, path_fmu, | ||
inputs_fmu=["infection_rate", "healing_rate"], | ||
outputs_fmu=["infected"], | ||
start_time=10) | ||
|
||
|
||
def test_start_time(path_fmu, mesh): | ||
"""Check if start times are taken into account.""" | ||
model_fmu_1 = otfmi.FMUPointToFieldFunction( | ||
mesh, | ||
path_fmu, | ||
inputs_fmu=["infection_rate", "healing_rate"], | ||
outputs_fmu=["infected"], | ||
start_time=0, | ||
) | ||
model_fmu_2 = otfmi.FMUPointToFieldFunction( | ||
mesh, | ||
path_fmu, | ||
inputs_fmu=["infection_rate", "healing_rate"], | ||
outputs_fmu=["infected"], | ||
start_time=1, | ||
) | ||
input_value = [0.007, 0.02] | ||
y1 = model_fmu_1(input_value) | ||
y2 = model_fmu_2(input_value) | ||
assert y2[0][0] - y1[0][0] != 0 | ||
|
||
|
||
def test_final_time_coherence(path_fmu, mesh): | ||
"""Check if incoherent final time raises an error.""" | ||
with pytest.raises(AssertionError): | ||
_ = otfmi.FMUPointToFieldFunction(mesh, path_fmu, | ||
inputs_fmu=["infection_rate", "healing_rate"], | ||
outputs_fmu=["infected"], | ||
final_time=10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters