[FIX] File: Disallow changing string columns to datetime#2050
[FIX] File: Disallow changing string columns to datetime#2050lanzagar merged 1 commit intobiolab:masterfrom jerneju:valueerror-owfile
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2050 +/- ##
==========================================
- Coverage 70.7% 69.66% -1.04%
==========================================
Files 315 315
Lines 53903 53903
==========================================
- Hits 38111 37554 -557
- Misses 15792 16349 +557Continue to review full report at Codecov.
|
|
This fixes the error nicely, but I was wondering whether we could provide the user with a better error message. Perhaps "Use ISO format for datetime variables (e.g. 2017-02-27)"? Say in a form of a warning? Just to tell the user how to proceed with datetime variables? :) |
|
ISO 8601? Yes, program knows how to read "2017-03-01" but have no clue what means "2017-03-01T12:49:39+00:00" ("could not convert string to float"). |
|
Complain to @kernc. It does work with 2017-03-01 12:49:39 though. |
|
Great, I see it does work with that kind of format. I changed the code in a way that a user message won't be necessary. Now only variables which can be set to numerical can also be set to datetime. |
astaric
left a comment
There was a problem hiding this comment.
While eventually we would prefer to allow user to specify the datetime format that would be able to parse the strings, this fix should prevent crashes in the mean time.
If possible, please add a test for the fix as well.
Orange/widgets/utils/domaineditor.py
Outdated
| ind = self.items.index(index.data()) | ||
| combo.addItems(self.items[:1] + self.items[1 + no_numeric:]) | ||
| combo.setCurrentIndex(ind - (no_numeric and ind > 1)) | ||
| combo.addItems(self.items[:1] + |
There was a problem hiding this comment.
IMHO, this would be much clearer if written like:
if no_numeric:
# Do not allow selection of numeric and datetime
items = [i for i in self.items if i not in ("numeric", "datetime")]
else:
items = self.items
ind = items.index(index.data())
combo.addItems(items)
combo.setCurrentIndex(ind)
ValueError - could not convert string to float: '02.02.17' https://sentry.io/biolab/orange3/issues/196743724/ Datetime option only if numerical.
|
Could you include a test? |
|
From the top of the head, the reason it didn't work with:
is that the colon in the timezone part doesn't parse with |
Issue
ValueError - could not convert string to float: '02.02.17'
https://sentry.io/biolab/orange3/issues/196743724/
Description of changes
Datetime option only if numerical.
Includes