Skip to content

Commit be2866a

Browse files
committed
update tests
1 parent baebaa7 commit be2866a

File tree

4 files changed

+13
-24
lines changed

4 files changed

+13
-24
lines changed

pandas/tests/indexes/datetimes/test_constructors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ def test_dti_tz_constructors(self, tzstr):
965965
start="2005-11-10 08:00:00", freq="h", periods=2, tz=tzstr, unit="s"
966966
)
967967
idx2 = idx2._with_freq(None) # the others all have freq=None
968-
idx3 = DatetimeIndex(arr, tz=tzstr).as_unit("s") # .as_unit("ns")
968+
idx3 = DatetimeIndex(arr, tz=tzstr).as_unit("s")
969969
idx4 = DatetimeIndex(np.array(arr), tz=tzstr).as_unit("s")
970970

971971
tm.assert_index_equal(idx1, idx2)

pandas/tests/reshape/concat/test_datetimes.py

-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ def test_concat_datetime_timezone(self):
6161
],
6262
freq="h",
6363
)
64-
.as_unit("ns")
65-
.tz_convert("UTC")
6664
.tz_convert("Europe/Paris")
6765
.as_unit("ns")
6866
)

pandas/tests/series/test_constructors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ def test_constructor_dtype_datetime64_10(self):
975975
# GH3414 related
976976
expected = Series(pydates, dtype="datetime64[ms]")
977977

978-
result = Series(Series(dates).view(np.int64) / 1000, dtype="M8[ms]")
978+
result = Series(Series(dates).astype(np.int64) / 1000, dtype="M8[ms]")
979979
tm.assert_series_equal(result, expected)
980980

981981
result = Series(dates, dtype="datetime64[ms]")

pandas/tests/tools/test_to_datetime.py

+11-20
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ def test_to_datetime_format_YYYYMMDD_with_none(self, input_s):
255255
def test_to_datetime_format_YYYYMMDD_overflow(self, input_s, expected):
256256
# GH 25512
257257
# format='%Y%m%d', errors='coerce'
258-
# expected = expected.dt.as_unit("ns")
259258
result = to_datetime(input_s, format="%Y%m%d", errors="coerce")
260259
tm.assert_series_equal(result, expected)
261260

@@ -277,7 +276,6 @@ def test_to_datetime_format_YYYYMMDD_overflow(self, input_s, expected):
277276
)
278277
def test_to_datetime_with_NA(self, data, format, expected):
279278
# GH#42957
280-
# expected = expected.as_unit("ns")
281279
result = to_datetime(data, format=format)
282280
tm.assert_index_equal(result, expected)
283281

@@ -494,7 +492,7 @@ def test_to_datetime_format_weeks(self, value, fmt, expected, cache):
494492
def test_to_datetime_parse_tzname_or_tzoffset(self, fmt, dates, expected_dates):
495493
# GH 13486
496494
result = to_datetime(dates, format=fmt)
497-
expected = Index(expected_dates) # .as_unit("ns")
495+
expected = Index(expected_dates)
498496
tm.assert_equal(result, expected)
499497

500498
@pytest.mark.parametrize(
@@ -554,7 +552,7 @@ def test_to_datetime_parse_tzname_or_tzoffset_different_tz_to_utc(self):
554552
fmt = "%Y-%m-%d %H:%M:%S %z"
555553

556554
result = to_datetime(dates, format=fmt, utc=True)
557-
expected = DatetimeIndex(expected_dates) # .as_unit("ns")
555+
expected = DatetimeIndex(expected_dates)
558556
tm.assert_index_equal(result, expected)
559557

560558
@pytest.mark.parametrize(
@@ -580,9 +578,7 @@ def test_to_datetime_parse_timezone_keeps_name(self):
580578
fmt = "%Y-%m-%d %H:%M:%S %z"
581579
arg = Index(["2010-01-01 12:00:00 Z"], name="foo")
582580
result = to_datetime(arg, format=fmt)
583-
expected = DatetimeIndex(
584-
["2010-01-01 12:00:00"], tz="UTC", name="foo"
585-
) # .as_unit("ns")
581+
expected = DatetimeIndex(["2010-01-01 12:00:00"], tz="UTC", name="foo")
586582
tm.assert_index_equal(result, expected)
587583

588584

@@ -615,9 +611,7 @@ def test_to_datetime_mixed_datetime_and_string(self):
615611
d1 = datetime(2020, 1, 1, 17, tzinfo=timezone(-timedelta(hours=1)))
616612
d2 = datetime(2020, 1, 1, 18, tzinfo=timezone(-timedelta(hours=1)))
617613
res = to_datetime(["2020-01-01 17:00 -0100", d2])
618-
expected = to_datetime([d1, d2]).tz_convert(
619-
timezone(timedelta(minutes=-60))
620-
) # .as_unit("ns")
614+
expected = to_datetime([d1, d2]).tz_convert(timezone(timedelta(minutes=-60)))
621615
tm.assert_index_equal(res, expected)
622616

623617
def test_to_datetime_mixed_string_and_numeric(self):
@@ -641,7 +635,7 @@ def test_to_datetime_mixed_date_and_string(self, format):
641635
# https://github.com/pandas-dev/pandas/issues/50108
642636
d1 = date(2020, 1, 2)
643637
res = to_datetime(["2020-01-01", d1], format=format)
644-
expected = DatetimeIndex(["2020-01-01", "2020-01-02"]) # .as_unit("ns")
638+
expected = DatetimeIndex(["2020-01-01", "2020-01-02"])
645639
tm.assert_index_equal(res, expected)
646640

647641
@pytest.mark.parametrize(
@@ -1140,7 +1134,7 @@ def test_to_datetime_dt64s(self, cache, dt):
11401134
def test_to_datetime_dt64s_and_str(self, arg, format):
11411135
# https://github.com/pandas-dev/pandas/issues/50036
11421136
result = to_datetime([arg, np.datetime64("2020-01-01")], format=format)
1143-
expected = DatetimeIndex(["2001-01-01", "2020-01-01"]) # .as_unit("ns")
1137+
expected = DatetimeIndex(["2001-01-01", "2020-01-01"])
11441138
tm.assert_index_equal(result, expected)
11451139

11461140
@pytest.mark.parametrize(
@@ -1734,11 +1728,11 @@ def test_iso_8601_strings_with_same_offset(self):
17341728
expected = Timestamp(ts_str)
17351729
assert result == expected
17361730

1737-
expected = DatetimeIndex([Timestamp(ts_str)] * 2) # .as_unit("ns")
1731+
expected = DatetimeIndex([Timestamp(ts_str)] * 2)
17381732
result = to_datetime([ts_str] * 2)
17391733
tm.assert_index_equal(result, expected)
17401734

1741-
result = DatetimeIndex([ts_str] * 2) # .as_unit("ns")
1735+
result = DatetimeIndex([ts_str] * 2)
17421736
tm.assert_index_equal(result, expected)
17431737

17441738
def test_iso_8601_strings_with_different_offsets(self):
@@ -3696,9 +3690,7 @@ def test_to_datetime_format_f_parse_nanos():
36963690
def test_to_datetime_mixed_iso8601():
36973691
# https://github.com/pandas-dev/pandas/issues/50411
36983692
result = to_datetime(["2020-01-01", "2020-01-01 05:00:00"], format="ISO8601")
3699-
expected = DatetimeIndex(
3700-
["2020-01-01 00:00:00", "2020-01-01 05:00:00"]
3701-
) # .as_unit("ns")
3693+
expected = DatetimeIndex(["2020-01-01 00:00:00", "2020-01-01 05:00:00"])
37023694
tm.assert_index_equal(result, expected)
37033695

37043696

@@ -3767,13 +3759,12 @@ def test_to_datetime_with_empty_str_utc_false_format_mixed():
37673759
# GH 50887
37683760
vals = ["2020-01-01 00:00+00:00", ""]
37693761
result = to_datetime(vals, format="mixed")
3770-
expected = Index([Timestamp("2020-01-01 00:00+00:00"), "NaT"], dtype="M8[ns, UTC]")
3762+
expected = Index([Timestamp("2020-01-01 00:00+00:00"), "NaT"], dtype="M8[s, UTC]")
37713763
tm.assert_index_equal(result, expected)
37723764

37733765
# Check that a couple of other similar paths work the same way
3774-
# FIXME: expect the same reso!
37753766
alt = to_datetime(vals)
3776-
tm.assert_index_equal(alt, expected.as_unit("s"))
3767+
tm.assert_index_equal(alt, expected)
37773768
alt2 = DatetimeIndex(vals)
37783769
tm.assert_index_equal(alt2, expected)
37793770

0 commit comments

Comments
 (0)