-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Index tests in the wrong places #18074
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
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5592796
Fix incorrectly-located as_type and to_period tests
jbrockmendel f71f735
Move union and difference tests;
jbrockmendel 21b642b
fix slice test locations
jbrockmendel 2427cc0
move slice test
jbrockmendel 111316e
reviewer suggestions; parameterize tests
jbrockmendel 846032f
Merge branch 'master' of https://github.com/pandas-dev/pandas into in…
jbrockmendel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,14 +11,31 @@ | |
START, END = datetime(2009, 1, 1), datetime(2010, 1, 1) | ||
|
||
|
||
class TestDatetimeIndex(object): | ||
class TestDatetimeIndexSetOps(object): | ||
tz = [None, 'UTC', 'Asia/Tokyo', 'US/Eastern', 'dateutil/Asia/Singapore', | ||
'dateutil/US/Pacific'] | ||
|
||
def test_union(self): | ||
i1 = Int64Index(np.arange(0, 20, 2)) | ||
i2 = Int64Index(np.arange(10, 30, 2)) | ||
result = i1.union(i2) | ||
expected = Int64Index(np.arange(0, 30, 2)) | ||
tm.assert_index_equal(result, expected) | ||
for tz in self.tz: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't use loops, parametrize |
||
# union | ||
rng1 = pd.date_range('1/1/2000', freq='D', periods=5, tz=tz) | ||
other1 = pd.date_range('1/6/2000', freq='D', periods=5, tz=tz) | ||
expected1 = pd.date_range('1/1/2000', freq='D', periods=10, tz=tz) | ||
|
||
rng2 = pd.date_range('1/1/2000', freq='D', periods=5, tz=tz) | ||
other2 = pd.date_range('1/4/2000', freq='D', periods=5, tz=tz) | ||
expected2 = pd.date_range('1/1/2000', freq='D', periods=8, tz=tz) | ||
|
||
rng3 = pd.date_range('1/1/2000', freq='D', periods=5, tz=tz) | ||
other3 = pd.DatetimeIndex([], tz=tz) | ||
expected3 = pd.date_range('1/1/2000', freq='D', periods=5, tz=tz) | ||
|
||
for rng, other, expected in [(rng1, other1, expected1), | ||
(rng2, other2, expected2), | ||
(rng3, other3, expected3)]: | ||
|
||
result_union = rng.union(other) | ||
tm.assert_index_equal(result_union, expected) | ||
|
||
def test_union_coverage(self): | ||
idx = DatetimeIndex(['2000-01-03', '2000-01-01', '2000-01-02']) | ||
|
@@ -155,6 +172,27 @@ def test_intersection_bug_1708(self): | |
result = index_1 & index_2 | ||
assert len(result) == 0 | ||
|
||
def test_difference(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
for tz in self.tz: | ||
# diff | ||
rng1 = pd.date_range('1/1/2000', freq='D', periods=5, tz=tz) | ||
other1 = pd.date_range('1/6/2000', freq='D', periods=5, tz=tz) | ||
expected1 = pd.date_range('1/1/2000', freq='D', periods=5, tz=tz) | ||
|
||
rng2 = pd.date_range('1/1/2000', freq='D', periods=5, tz=tz) | ||
other2 = pd.date_range('1/4/2000', freq='D', periods=5, tz=tz) | ||
expected2 = pd.date_range('1/1/2000', freq='D', periods=3, tz=tz) | ||
|
||
rng3 = pd.date_range('1/1/2000', freq='D', periods=5, tz=tz) | ||
other3 = pd.DatetimeIndex([], tz=tz) | ||
expected3 = pd.date_range('1/1/2000', freq='D', periods=5, tz=tz) | ||
|
||
for rng, other, expected in [(rng1, other1, expected1), | ||
(rng2, other2, expected2), | ||
(rng3, other3, expected3)]: | ||
result_diff = rng.difference(other) | ||
tm.assert_index_equal(result_diff, expected) | ||
|
||
def test_difference_freq(self): | ||
# GH14323: difference of DatetimeIndex should not preserve frequency | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can remove this comment FYI