Skip to content

Commit 050004c

Browse files
authored
Merge pull request #1760 from kernc/fixup
[FIX] TimeVariable: don't crash Data Table when reloading and Visualize ...
2 parents b896110 + c9b7d0e commit 050004c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Orange/data/variable.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ def repr_val(self, val):
921921
return '?'
922922
if not self.have_date and not self.have_time:
923923
# The time is relative, unitless. The value is absolute.
924-
return str(val)
924+
return str(val.value) if isinstance(val, Value) else str(val)
925925

926926
# If you know how to simplify this, be my guest
927927
seconds = int(val)

Orange/tests/test_variable.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,10 @@ def test_readwrite_timevariable(self):
382382
self.assertEqual(input_csv.getvalue().splitlines(),
383383
output_csv.getvalue().splitlines())
384384

385+
def test_repr_value(self):
386+
# https://github.com/biolab/orange3/pull/1760
387+
var = TimeVariable('time')
388+
self.assertEqual(var.repr_val(Value(var, 416.3)), '416.3')
385389

386390

387391
PickleContinuousVariable = create_pickling_tests(

0 commit comments

Comments
 (0)