-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Implement _most_ of the EA interface for DTA/TDA #23643
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
Changes from 1 commit
52e4d6b
c2bcd80
0ce0a7c
45c8161
75f6944
0fb5029
1a781ab
ccbffe4
eceebc7
a6065cc
3cb072e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,60 +58,60 @@ def timedelta_index(request): | |
|
||
class SharedTests(object): | ||
index_cls = None | ||
|
||
def test_take(self): | ||
data = np.arange(100, dtype='i8') | ||
np.random.shuffle(data) | ||
|
||
idx = self.index_cls._simple_new(data, freq='D') | ||
arr = self.array_cls(idx) | ||
|
||
takers = [1, 4, 94] | ||
result = arr.take(takers) | ||
expected = idx.take(takers) | ||
|
||
tm.assert_index_equal(self.index_cls(result), expected) | ||
|
||
takers = np.array([1, 4, 94]) | ||
result = arr.take(takers) | ||
expected = idx.take(takers) | ||
|
||
tm.assert_index_equal(self.index_cls(result), expected) | ||
|
||
def test_take_fill(self): | ||
data = np.arange(10, dtype='i8') | ||
|
||
idx = self.index_cls._simple_new(data, freq='D') | ||
arr = self.array_cls(idx) | ||
|
||
result = arr.take([-1, 1], allow_fill=True, fill_value=None) | ||
assert result[0] is pd.NaT | ||
|
||
result = arr.take([-1, 1], allow_fill=True, fill_value=np.nan) | ||
assert result[0] is pd.NaT | ||
|
||
result = arr.take([-1, 1], allow_fill=True, fill_value=pd.NaT) | ||
assert result[0] is pd.NaT | ||
|
||
with pytest.raises(ValueError): | ||
arr.take([0, 1], allow_fill=True, fill_value=2) | ||
|
||
with pytest.raises(ValueError): | ||
arr.take([0, 1], allow_fill=True, fill_value=2.0) | ||
|
||
with pytest.raises(ValueError): | ||
arr.take([0, 1], allow_fill=True, | ||
fill_value=pd.Timestamp.now().time) | ||
|
||
def test_concat_same_type(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. As I think also commented on one of the previous PRs that started doing this, I don't think we should test 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. Yah, most of these tests were salvaged from one of those older PRs. I don't see much downside to having the tests, but am pretty happy to pawn this decision/PR off on Tom 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. We still want the fail cases (different dtypes) here. At this point, we should be able to simplify |
||
data = np.arange(10, dtype='i8') | ||
|
||
idx = self.index_cls._simple_new(data, freq='D').insert(0, pd.NaT) | ||
arr = self.array_cls(idx) | ||
|
||
result = arr._concat_same_type([arr[:-1], arr[1:], arr]) | ||
expected = idx._concat_same_dtype([idx[:-1], idx[1:], idx], None) | ||
|
||
tm.assert_index_equal(self.index_cls(result), expected) | ||
|
||
|
||
|
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.
We should not need to add such basic tests I think, as those are covered by the base Extension tests (we should of course test datetime specific aspects).
Is there anything in this test not tested by the base tests?
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.
The class-specific tests have tests for invalid fill_values