Skip to content

Commit c9b7d0e

Browse files
committed
TimeVariable: don't crash Data Table when reloading and visualize continuous
Fixes #1734 (comment) Traceback (most recent call last): File "/home/lan/dev/orange3/Orange/widgets/utils/itemmodels.py", line 1112, in data return coldesc.format(instance) File "/home/lan/dev/orange3/Orange/widgets/utils/itemmodels.py", line 863, in format_dense return str(instance[var]) File "/home/lan/dev/orange3/Orange/data/variable.py", line 166, in __str__ return self.variable.str_val(self) File "/home/lan/dev/orange3/Orange/data/variable.py", line 924, in repr_val return str(val) File "/home/lan/dev/orange3/Orange/data/variable.py", line 166, in __str__ return self.variable.str_val(self) ... RecursionError: maximum recursion depth exceeded while calling a Python object
1 parent 7b5f2be commit c9b7d0e

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)