diff --git a/Orange/widgets/data/owfeatureconstructor.py b/Orange/widgets/data/owfeatureconstructor.py index 059929a63c9..cf745a13979 100644 --- a/Orange/widgets/data/owfeatureconstructor.py +++ b/Orange/widgets/data/owfeatureconstructor.py @@ -1213,6 +1213,8 @@ def extract_column(self, table: Table, var: Variable): idx = data.astype(int) idx[~np.isfinite(data)] = len(values) - 1 return values[idx].tolist() + elif var.is_time: # time always needs Values due to str(val) formatting + return Value._as_values(var, data.tolist()) # pylint: disable=protected-access elif not self.use_values: return data.tolist() else: diff --git a/Orange/widgets/data/tests/test_owfeatureconstructor.py b/Orange/widgets/data/tests/test_owfeatureconstructor.py index 11147737598..0f708411f7a 100644 --- a/Orange/widgets/data/tests/test_owfeatureconstructor.py +++ b/Orange/widgets/data/tests/test_owfeatureconstructor.py @@ -305,6 +305,12 @@ def test_missing_variable(self): self.assertTrue(np.all(np.isnan(r))) self.assertTrue(np.isnan(f(data2[0]))) + def test_time_str(self): + data = Table.from_numpy(Domain([TimeVariable("T", have_date=True)]), [[0], [0]]) + f = FeatureFunc("str(T)", [("T", data.domain[0])]) + c = f(data) + self.assertEqual(c, ["1970-01-01", "1970-01-01"]) + def test_invalid_expression_variable(self): iris = Table("iris") f = FeatureFunc("1 / petal_length",