Skip to content

Commit

Permalink
test_pandas: Don't import pytz for newer pandas
Browse files Browse the repository at this point in the history
  • Loading branch information
janezd committed Sep 23, 2024
1 parent ed02e75 commit 8347967
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions Orange/data/tests/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

import numpy as np
import pandas as pd
import pytz
if pd.__version__ < "2":
import pytz
else:
pytz = None
from scipy.sparse import csr_matrix
import scipy.sparse as sp

Expand Down Expand Up @@ -307,7 +310,7 @@ def test_table_from_frame_timezones(self):
]
)
table = table_from_frame(df)
tz = pytz.utc if pd.__version__ < "2" else timezone.utc
tz = pytz.utc if pytz is not None else timezone.utc
self.assertEqual(tz, table.domain.variables[0].timezone)
np.testing.assert_equal(
table.X,
Expand All @@ -326,7 +329,7 @@ def test_table_from_frame_timezones(self):
]
)
table = table_from_frame(df)
tz = pytz.FixedOffset(60) if pd.__version__ < "2" else \
tz = pytz.FixedOffset(60) if pytz is not None else \
timezone(timedelta(seconds=3600))
self.assertEqual(tz, table.domain.variables[0].timezone)
np.testing.assert_equal(
Expand All @@ -345,12 +348,6 @@ def test_table_from_frame_timezones(self):
[np.nan],
]
)
table = table_from_frame(df)
self.assertEqual(pytz.timezone("CET"), table.domain.variables[0].timezone)
# Testing the table was removed because a change in pytz broke it:
# treatment of DST has changed, so test were off by an hour,
# while time zones before ~1930 seem to be off by 42 minutes
# We could fix this, but prefer not to test pytz regressions.

df = pd.DataFrame(
[
Expand All @@ -360,7 +357,7 @@ def test_table_from_frame_timezones(self):
]
)
table = table_from_frame(df)
tz = pytz.utc if pd.__version__ < "2" else timezone.utc
tz = pytz.utc if pytz is not None else timezone.utc
self.assertEqual(tz, table.domain.variables[0].timezone)
np.testing.assert_equal(
table.X,
Expand Down

0 comments on commit 8347967

Please sign in to comment.