Skip to content

Commit 6750709

Browse files
Fix pandas equality tests for Python 3.9 more more
1 parent dbb1805 commit 6750709

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

pvlib/tests/test_tools.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
from datetime import datetime
32
from zoneinfo import ZoneInfo
43

@@ -273,18 +272,12 @@ def test_normalize_max2one(data_in, expected):
273272
],
274273
)
275274
def test_localize_to_utc(input, expected):
276-
# Pandas has bad dtype check in Python 3.9.
277-
if (sys.version_info[0], sys.version_info[1]) == (3, 9):
278-
check_dtype = False
279-
else:
280-
check_dtype = True
281-
282275
got = tools.localize_to_utc(**input)
283276

284-
if isinstance(got, pd.Series):
285-
pd.testing.assert_series_equal(got, expected, check_dtype=check_dtype)
286-
elif isinstance(got, pd.DataFrame):
287-
pd.testing.assert_frame_equal(got, expected, check_dtype=check_dtype)
277+
# Pandas has wonky dtype check in Python 3.9.
278+
if isinstance(got, (pd.Series, pd.DataFrame)):
279+
pd.testing.assert_index_equal(got.index, expected.index)
280+
np.testing.assert_array_equal(got.to_numpy(), expected.to_numpy())
288281
else:
289282
assert got == expected
290283

0 commit comments

Comments
 (0)