Skip to content

Commit

Permalink
Merge pull request #1 from Kislovskiy/non-ns-time
Browse files Browse the repository at this point in the history
  • Loading branch information
brisvag authored Sep 5, 2022
2 parents ffc70e3 + 55f75dc commit 7c0765e
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions pandas/tests/series/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1579,11 +1579,11 @@ def test_convert_non_ns(self):
tm.assert_series_equal(ser, expected)

# try to construct from a sequence asking for non-ns timedelta64
with pytest.raises(TypeError, match=r"Only \[ns\] granularity"):
with pytest.raises(TypeError, match=r"Only \[ns\] granularity is supported"):
Series([1000000, 200000, 3000000], dtype="timedelta64[s]")

# try to construct from a sequence asking for non-ns datetime64
with pytest.raises(TypeError, match=r"Only \[ns\] granularity"):
with pytest.raises(TypeError, match=r"Only \[ns\] granularity is supported"):
Series([1000000, 200000, 3000000], dtype="datetime64[s]")

@pytest.mark.parametrize(
Expand Down Expand Up @@ -1650,8 +1650,8 @@ def test_constructor_generic_timestamp_no_frequency(self, dtype, request):
@pytest.mark.parametrize(
"dtype,msg",
[
("m8[ps]", "cannot convert timedeltalike"),
("M8[ps]", "cannot convert datetimelike"),
("m8[ps]", "Only \[ns\] granularity is supported"),
("M8[ps]", "Only \[ns\] granularity is supported"),
],
)
def test_constructor_generic_timestamp_bad_frequency(self, dtype, msg):
Expand Down Expand Up @@ -1894,22 +1894,6 @@ def test_constructor_dtype_timedelta_alternative_construct(self):
expected = Series(pd.to_timedelta([1000000, 200000, 3000000], unit="ns"))
tm.assert_series_equal(result, expected)

def test_constructor_dtype_timedelta_ns_s(self):
# GH#35465
result = Series([1000000, 200000, 3000000], dtype="timedelta64[ns]")
expected = Series([1000000, 200000, 3000000], dtype="timedelta64[s]")
tm.assert_series_equal(result, expected)

def test_constructor_dtype_timedelta_ns_s_astype_int64(self):
# GH#35465
result = Series([1000000, 200000, 3000000], dtype="timedelta64[ns]").astype(
"int64"
)
expected = Series([1000000, 200000, 3000000], dtype="timedelta64[s]").astype(
"int64"
)
tm.assert_series_equal(result, expected)

@pytest.mark.filterwarnings(
"ignore:elementwise comparison failed:DeprecationWarning"
)
Expand Down

0 comments on commit 7c0765e

Please sign in to comment.