Skip to content

Commit

Permalink
Resolve Edit Domain (datetime to epoch) timebomb
Browse files Browse the repository at this point in the history
  • Loading branch information
PrimozGodec committed Jan 8, 2023
1 parent 975aaf5 commit 400d288
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 20 deletions.
5 changes: 0 additions & 5 deletions Orange/widgets/data/oweditdomain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2837,11 +2837,6 @@ def datetime_to_epoch(dti: pd.DatetimeIndex, only_time) -> np.ndarray:
# when dti has timezone info also the subtracted timestamp must have it
# otherwise subtracting fails
initial_ts = pd.Timestamp("1970-01-01", tz=None if dti.tz is None else "UTC")
# pandas in versions before 1.4 don't support subtracting different timezones
# remove next two lines when read-the-docs start supporting config files
# for subprojects, or they change default python version to 3.8
if dti.tz is not None:
dti = dti.tz_convert("UTC")
delta = dti - (dti.normalize() if only_time else initial_ts)
return (delta / pd.Timedelta("1s")).values

Expand Down
2 changes: 0 additions & 2 deletions Orange/widgets/data/owgroupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ def var(s):
"""
if is_datetime64_any_dtype(s):
initial_ts = pd.Timestamp("1970-01-01", tz=None if s.dt.tz is None else "UTC")
if s.dt.tz is not None:
s = s.tz_convert("UTC")
s = (s - initial_ts) / pd.Timedelta("1s")
var_ = s.var()
return var_.total_seconds() if isinstance(var_, pd.Timedelta) else var_
Expand Down
11 changes: 0 additions & 11 deletions Orange/widgets/data/tests/test_oweditdomain.py
Original file line number Diff line number Diff line change
Expand Up @@ -957,17 +957,6 @@ def test_as_time(self):
np.array(list(chain(expected, expected)), dtype=float).transpose()
)

def test_raise_pandas_version(self):
"""
When this test start to fail:
- remove this test
- remove if clause in datetime_to_epoch function and supporting comments
- remove same if clause in var function in owgroupby (line 77, 78)
- set pandas dependency version to pandas>=1.4
"""
from datetime import datetime
self.assertLess(datetime.today(), datetime(2023, 1, 1))

def test_reinterpret_string(self):
table = self.data_str
domain = table.domain
Expand Down
2 changes: 1 addition & 1 deletion requirements-core.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ python-louvain>=0.13
requests
openTSNE>=0.6.1
baycomp>=1.0.2
pandas>=1.3.0,!=1.5.0
pandas>=1.4.0,!=1.5.0
pyyaml
openpyxl
httpx>=0.21.0
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ deps =
# oldest: requests
oldest: openTSNE==0.6.1
oldest: baycomp==1.0.2
oldest: pandas==1.3.0
oldest: pandas==1.4.0
# oldest: pyyaml
# oldest: openpyxl
oldest: httpx==0.21.0
Expand Down

0 comments on commit 400d288

Please sign in to comment.