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

don't separately test initialize(); allow testing even if initial value of array is NaN #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all 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
20 changes: 13 additions & 7 deletions bmi_tester/bmitester.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
assert_greater, assert_in)

from .termcolors import red, green, yellow, blink
import math

# from components import InfilGreenAmpt as Component

Expand Down Expand Up @@ -383,9 +384,9 @@ def test_get_time_units(self):
assert_in(units, ('s', 'seconds', 'd', 'days', 'y', 'years'))
return units

#def test_get_value(self):
# get_value() is tested via test_get_input_values() and
# test_get_output_values()
# get_value() is tested via test_get_input_values() and
# test_get_output_values() and is not tested separately
# def test_get_value(self):

def test_get_input_values(self):
"""Input values are numpy arrays."""
Expand Down Expand Up @@ -515,9 +516,11 @@ def test_get_var_units(self):
names = set(self.bmi.get_input_var_names()) | set(self.bmi.get_output_var_names())
self.foreach(names, self._test_var_units)

def test_initialize(self):
"""Test initialization from a file."""
self.bmi.initialize(self._file)
# initialize is called by __init__() and therefore
# does not need a separate test
# def test_initialize(self):
# """Test initialization from a file."""
# self.bmi.initialize(self._file)

def test_get_value_and_set_value(self):
"""Test if we can get and set the value of (input) variables"""
Expand Down Expand Up @@ -569,7 +572,10 @@ def _test():
val_first_value = val[0, 0, 0]

# Replace the first value of the array with a new value
val_test_value += val_first_value + 1
if math.isnan(val_first_value):
val_test_value = 1
else:
val_test_value += val_first_value + 1
if valrank == 1:
self.bmi.set_value_at_indices(name,
[0], val_test_value)
Expand Down