You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Check Functions do not display datetime comparisons helpfully #98
Comparing datetime functions in a chk_* will show .3g instead of the repr for the datetime object. This could overflow into other object time comparisons that are not float or integer based.
Had a go at replicating this issue but without any luck. Ended up writing some tests for chk_smaller.
They're in my fix-time-checks fork in Fixate/test/core/test_checks.py if it helps.
def round_to_3_sig_figures(chk):
"""
Tries to round elements to 3 significant figures for formatting
:param chk:
:return:
"""
ret_dict = {}
for element in ["_min", "_max", "test_val", "nominal", "tol"]:
ret_dict[element] = getattr(chk, element, None)
try:
ret_dict[element] = "{:.3g}".format(ret_dict[element])
except:
pass
return ret_dict
format with decimal places does not produce the desired output but does not raise an error when datetime object is used.
Adding an assert math.isclose within the try: rejects the change of format, allowing the original formatting (standard datetime object output) to be shown:
Check 1: PASS when comparing 2.5 in range 2 - 3 :
Check 2: PASS when comparing 2019-01-01 00:00:00 in range 2018-12-31
23:59:58 - 2019-04-08 21:52:25.021197 :
Activity
Tests for chk_smaller added in an effort to find the reported timedat…
christopherwallis commentedon Apr 2, 2019
Had a go at replicating this issue but without any luck. Ended up writing some tests for chk_smaller.
They're in my fix-time-checks fork in Fixate/test/core/test_checks.py if it helps.
clint-lawrence commentedon Apr 3, 2019
@pazzarpj, have you got a script that shows the error? or can you write a failing test?
pazzarpj commentedon Apr 5, 2019
Expected output
Actual
christopherwallis commentedon Apr 5, 2019
There seems to be an issue with timestruct objects as well in that script. They're displayed with their data but always pass:
However the issue doesn't seem to occur when using chk_in_range for either timestruct or datetime objects as the following tests pass:
pazzarpj commentedon Apr 5, 2019
The script I provided was to demonstrate the display issue, the CheckClass doesn't actually run the check.
_print_comparisons first parameter determines if it displays as pass/fail.
The issue is that the _print_comparisons function assumes a number with the {:.3g} string formatter.
christopherwallis commentedon Apr 5, 2019
Riiight, i finally get it now. I'll stop barking up the wrong tree. Will look into it when i get a chance. Thanks for slow walking me there.
christopherwallis commentedon Apr 8, 2019
Issue found in ui_cmdline\cmd_line.py line 304:
format with decimal places does not produce the desired output but does not raise an error when datetime object is used.
Adding an assert math.isclose within the try: rejects the change of format, allowing the original formatting (standard datetime object output) to be shown:
Will run a few more tests and upload the code.