Skip to content

Commit f9534d9

Browse files
author
Theofilos Manitaras
committed
Address PR comments
1 parent 126fa7a commit f9534d9

File tree

3 files changed

+14
-26
lines changed

3 files changed

+14
-26
lines changed

docs/tutorial.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ The first occurrence will be used as the reference value of the ``perf`` perform
824824
In our example, the ``perf`` key will be resolved in the ``daint:gpu`` scope giving us the reference value.
825825

826826
Reference values in ReFrame are specified as a three-tuple comprising the reference value and lower and upper thresholds.
827-
Thresholds are specified as decimal fractions of the reference value. For nonnegative reference values, the lower threshold must lie in the [-1,0], whereas the upper threshold must lie in the [0,inf] interval.
827+
Thresholds are specified as decimal fractions of the reference value. For nonnegative reference values, the lower threshold must lie in the [-1,0], whereas the upper threshold may be any positive real number or zero.
828828
In our example, the reference value for this test on ``daint:gpu`` is 50 Gflop/s ±10%. Setting a threshold value to :class:`None` disables the threshold.
829829

830830
Combining It All Together

reframe/utility/sanity.py

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -483,28 +483,20 @@ def assert_reference(val, ref, lower_thres=None, upper_thres=None, msg=None):
483483
lower and upper thresholds do not have appropriate values.
484484
"""
485485
if lower_thres is not None:
486-
if ref >= 0.0:
487-
try:
488-
evaluate(assert_bounded(lower_thres, -1, 0))
489-
except SanityError:
490-
raise SanityError('invalid low threshold value: %s' % lower_thres)
491-
else:
492-
try:
493-
evaluate(assert_bounded(lower_thres, None, 0))
494-
except SanityError:
495-
raise SanityError('invalid low threshold value: %s' % lower_thres)
486+
lower_thres_limit = -1 if ref >= 0 else None
487+
try:
488+
evaluate(assert_bounded(lower_thres, lower_thres_limit, 0))
489+
except SanityError:
490+
raise SanityError('invalid low threshold value: %s'
491+
% lower_thres) from None
496492

497493
if upper_thres is not None:
498-
if ref >= 0.0:
499-
try:
500-
evaluate(assert_bounded(upper_thres, 0, None))
501-
except SanityError:
502-
raise SanityError('invalid high threshold value: %s' % upper_thres)
503-
else:
504-
try:
505-
evaluate(assert_bounded(upper_thres, 0, 1))
506-
except SanityError:
507-
raise SanityError('invalid high threshold value: %s' % upper_thres)
494+
upper_thres_limit = None if ref >= 0 else 1
495+
try:
496+
evaluate(assert_bounded(upper_thres, 0, upper_thres_limit))
497+
except SanityError:
498+
raise SanityError('invalid high threshold value: %s'
499+
% upper_thres) from None
508500

509501
def calc_bound(thres):
510502
if thres is None:

unittests/test_sanity_functions.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,7 @@ def test_assert_reference(self):
341341
self.assertTrue(sn.assert_reference(-0.9, -1))
342342

343343
# Check upper threshold values greater than 1
344-
self.assertTrue(sn.assert_reference(30.0, 10.0, None, 3.0))
345-
self.assertTrue(sn.assert_reference(-50.0, -20.0, -2.0, 0.5))
346-
self.assertTrue(sn.assert_reference(30.0, 10.0, None, 3.0))
344+
self.assertTrue(sn.assert_reference(20.0, 10.0, None, 3.0))
347345
self.assertTrue(sn.assert_reference(-50.0, -20.0, -2.0, 0.5))
348346

349347
self.assertRaisesRegex(
@@ -392,8 +390,6 @@ def test_assert_reference(self):
392390
'invalid high threshold value: 1\.5',
393391
evaluate, sn.assert_reference(-1.5, -1, -0.5, 1.5))
394392

395-
396-
397393
def _write_tempfile(self):
398394
ret = None
399395
with NamedTemporaryFile('wt', delete=False) as fp:

0 commit comments

Comments
 (0)