Skip to content

REF: move misplaced tests #31189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions pandas/tests/indexes/datetimes/test_snap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import pytest

from pandas import DatetimeIndex, date_range
import pandas._testing as tm


@pytest.mark.filterwarnings("ignore::DeprecationWarning")
@pytest.mark.parametrize("tz", [None, "Asia/Shanghai", "Europe/Berlin"])
@pytest.mark.parametrize("name", [None, "my_dti"])
def test_dti_snap(name, tz):
dti = DatetimeIndex(
[
"1/1/2002",
"1/2/2002",
"1/3/2002",
"1/4/2002",
"1/5/2002",
"1/6/2002",
"1/7/2002",
],
name=name,
tz=tz,
freq="D",
)

result = dti.snap(freq="W-MON")
expected = date_range("12/31/2001", "1/7/2002", name=name, tz=tz, freq="w-mon")
expected = expected.repeat([3, 4])
tm.assert_index_equal(result, expected)
assert result.tz == expected.tz

result = dti.snap(freq="B")

expected = date_range("1/1/2002", "1/7/2002", name=name, tz=tz, freq="b")
expected = expected.repeat([1, 1, 1, 2, 2])
tm.assert_index_equal(result, expected)
assert result.tz == expected.tz
11 changes: 11 additions & 0 deletions pandas/tests/indexes/multi/test_setops.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ def test_symmetric_difference(idx, sort):
first.symmetric_difference([1, 2, 3], sort=sort)


def test_multiindex_symmetric_difference():
# GH 13490
idx = MultiIndex.from_product([["a", "b"], ["A", "B"]], names=["a", "b"])
result = idx ^ idx
assert result.names == idx.names

idx2 = idx.copy().rename(["A", "B"])
result = idx ^ idx2
assert result.names == [None, None]


def test_empty(idx):
# GH 15270
assert not idx.empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,7 @@
import pandas._testing as tm


class TestMultiIndexSetOps:
def test_multiindex_symmetric_difference(self):
# GH 13490
idx = MultiIndex.from_product([["a", "b"], ["A", "B"]], names=["a", "b"])
result = idx ^ idx
assert result.names == idx.names

idx2 = idx.copy().rename(["A", "B"])
result = idx ^ idx2
assert result.names == [None, None]

class TestMultiIndexInsertion:
def test_mixed_depth_insert(self):
arrays = [
["a", "top", "top", "routine1", "routine1", "routine2"],
Expand Down
43 changes: 0 additions & 43 deletions pandas/tests/series/indexing/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,39 +49,6 @@ def test_fancy_setitem():
assert (s[48:54] == -3).all()


@pytest.mark.filterwarnings("ignore::DeprecationWarning")
@pytest.mark.parametrize("tz", [None, "Asia/Shanghai", "Europe/Berlin"])
@pytest.mark.parametrize("name", [None, "my_dti"])
def test_dti_snap(name, tz):
dti = DatetimeIndex(
[
"1/1/2002",
"1/2/2002",
"1/3/2002",
"1/4/2002",
"1/5/2002",
"1/6/2002",
"1/7/2002",
],
name=name,
tz=tz,
freq="D",
)

result = dti.snap(freq="W-MON")
expected = date_range("12/31/2001", "1/7/2002", name=name, tz=tz, freq="w-mon")
expected = expected.repeat([3, 4])
tm.assert_index_equal(result, expected)
assert result.tz == expected.tz

result = dti.snap(freq="B")

expected = date_range("1/1/2002", "1/7/2002", name=name, tz=tz, freq="b")
expected = expected.repeat([1, 1, 1, 2, 2])
tm.assert_index_equal(result, expected)
assert result.tz == expected.tz


def test_dti_reset_index_round_trip():
dti = date_range(start="1/1/2001", end="6/1/2001", freq="D")
d1 = DataFrame({"v": np.random.rand(len(dti))}, index=dti)
Expand Down Expand Up @@ -751,16 +718,6 @@ def test_nat_operations():
assert s.max() == exp


@pytest.mark.parametrize("method", ["round", "floor", "ceil"])
@pytest.mark.parametrize("freq", ["s", "5s", "min", "5min", "h", "5h"])
def test_round_nat(method, freq):
# GH14940
s = Series([pd.NaT])
expected = Series(pd.NaT)
round_method = getattr(s.dt, method)
tm.assert_series_equal(round_method(freq), expected)


def test_setitem_tuple_with_datetimetz():
# GH 20441
arr = date_range("2017", periods=4, tz="US/Eastern")
Expand Down
10 changes: 10 additions & 0 deletions pandas/tests/series/methods/test_round.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
import pytest

import pandas as pd
from pandas import Series
import pandas._testing as tm

Expand Down Expand Up @@ -44,3 +45,12 @@ def test_round_builtin(self):
expected_rounded = Series([1.12, 2.12, 3.12], index=range(3))
result = round(ser, decimals)
tm.assert_series_equal(result, expected_rounded)

@pytest.mark.parametrize("method", ["round", "floor", "ceil"])
@pytest.mark.parametrize("freq", ["s", "5s", "min", "5min", "h", "5h"])
def test_round_nat(self, method, freq):
# GH14940
ser = Series([pd.NaT])
expected = Series(pd.NaT)
round_method = getattr(ser.dt, method)
tm.assert_series_equal(round_method(freq), expected)