-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST/REF: collect tests by method #37449
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 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b41ff56
TST/REF: collect tests by method
jbrockmendel 1686395
TST/REF: collect tests by method
jbrockmendel e6c0d6d
Merge branch 'master' of https://github.com/pandas-dev/pandas into ts…
jbrockmendel dd67093
Merge branch 'master' of https://github.com/pandas-dev/pandas into ts…
jbrockmendel 2338b10
Merge branch 'master' of https://github.com/pandas-dev/pandas into ts…
jbrockmendel c716822
Merge branch 'master' of https://github.com/pandas-dev/pandas into ts…
jbrockmendel d265783
move TestAsArray to test_conversion
jbrockmendel 0b53bb1
Merge branch 'master' of https://github.com/pandas-dev/pandas into ts…
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
""" | ||
Tests for np.foo applied to Series, not necessarily ufuncs. | ||
""" | ||
|
||
import numpy as np | ||
import pytest | ||
|
||
from pandas import Series, Timestamp, date_range | ||
import pandas._testing as tm | ||
|
||
|
||
class TestAsArray: | ||
@pytest.mark.parametrize("tz", [None, "US/Central"]) | ||
def test_asarray_object_dt64(self, tz): | ||
ser = Series(date_range("2000", periods=2, tz=tz)) | ||
|
||
with tm.assert_produces_warning(None): | ||
# Future behavior (for tzaware case) with no warning | ||
result = np.asarray(ser, dtype=object) | ||
|
||
expected = np.array( | ||
[Timestamp("2000-01-01", tz=tz), Timestamp("2000-01-02", tz=tz)] | ||
) | ||
tm.assert_numpy_array_equal(result, expected) | ||
|
||
def test_asarray_tz_naive(self): | ||
# This shouldn't produce a warning. | ||
ser = Series(date_range("2000", periods=2)) | ||
expected = np.array(["2000-01-01", "2000-01-02"], dtype="M8[ns]") | ||
result = np.asarray(ser) | ||
|
||
tm.assert_numpy_array_equal(result, expected) | ||
|
||
def test_asarray_tz_aware(self): | ||
tz = "US/Central" | ||
ser = Series(date_range("2000", periods=2, tz=tz)) | ||
expected = np.array(["2000-01-01T06", "2000-01-02T06"], dtype="M8[ns]") | ||
result = np.asarray(ser, dtype="datetime64[ns]") | ||
|
||
tm.assert_numpy_array_equal(result, expected) | ||
|
||
# Old behavior with no warning | ||
result = np.asarray(ser, dtype="M8[ns]") | ||
|
||
tm.assert_numpy_array_equal(result, expected) | ||
|
||
|
||
class TestPtp: | ||
def test_ptp(self): | ||
# GH#21614 | ||
N = 1000 | ||
arr = np.random.randn(N) | ||
ser = Series(arr) | ||
assert np.ptp(ser) == np.ptp(arr) |
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.
hmm, these are not npfuncs, i think this would be better in a test_datetimes?
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.
its for
np.asarray
current plan is to get rid of tests.(series|frame).test_datetimes
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.
i get it but these are pure conversion tests should be located with to_numpy() for example and it ufuncs themselves
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.
there is already a dedicated test_ufuncs.py.
The idea behind the collect-by-method approach is for it to be really obvious where a test belongs. to_numpy gets tested in test_to_numpy, .values gets tested in test_values.
np.array is an odd duck because it isnt one of our methods, so this may not be the best long-term place for this (ive been looking at tests.base which has tests shared between Index/Series which this might fit into eventually). how about we revisit this in a few weeks when (hopefully) we're closer to the end of this process
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.
hmm i would just move it now
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.
updated to move these to tests.base.test_conversion