-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
TST/REF: collect tests from test_api into method-specific files #37525
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 all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0983e83
TST/REF: method specific test files
jbrockmendel 3f4b37a
test_nonzero->test_empty
jbrockmendel 4931373
Merge branch 'master' of https://github.com/pandas-dev/pandas into ts…
jbrockmendel 04402aa
misplaced append test
jbrockmendel c167c7b
collect copy tests
jbrockmendel ba255e3
remove now-duplicated test
jbrockmendel 91d74ce
rename test_analytics -> test_reductions
jbrockmendel e5d57d7
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import pytest | ||
|
||
from pandas import DataFrame | ||
import pandas._testing as tm | ||
|
||
|
||
class TestCopy: | ||
@pytest.mark.parametrize("attr", ["index", "columns"]) | ||
def test_copy_index_name_checking(self, float_frame, attr): | ||
# don't want to be able to modify the index stored elsewhere after | ||
# making a copy | ||
ind = getattr(float_frame, attr) | ||
ind.name = None | ||
cp = float_frame.copy() | ||
getattr(cp, attr).name = "foo" | ||
assert getattr(float_frame, attr).name is None | ||
|
||
def test_copy_cache(self): | ||
# GH#31784 _item_cache not cleared on copy causes incorrect reads after updates | ||
df = DataFrame({"a": [1]}) | ||
|
||
df["x"] = [0] | ||
df["a"] | ||
|
||
df.copy() | ||
|
||
df["a"].values[0] = -1 | ||
|
||
tm.assert_frame_equal(df, DataFrame({"a": [-1], "x": [0]})) | ||
|
||
df["y"] = [0] | ||
|
||
assert df["a"].values[0] == -1 | ||
tm.assert_frame_equal(df, DataFrame({"a": [-1], "x": [0], "y": [0]})) | ||
|
||
def test_copy(self, float_frame, float_string_frame): | ||
cop = float_frame.copy() | ||
cop["E"] = cop["A"] | ||
assert "E" not in float_frame | ||
|
||
# copy objects | ||
copy = float_string_frame.copy() | ||
assert copy._mgr is not float_string_frame._mgr |
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,32 @@ | ||
import numpy as np | ||
|
||
from pandas import DataFrame, Timestamp | ||
import pandas._testing as tm | ||
|
||
|
||
class TestToNumpy: | ||
def test_to_numpy(self): | ||
df = DataFrame({"A": [1, 2], "B": [3, 4.5]}) | ||
expected = np.array([[1, 3], [2, 4.5]]) | ||
result = df.to_numpy() | ||
tm.assert_numpy_array_equal(result, expected) | ||
|
||
def test_to_numpy_dtype(self): | ||
df = DataFrame({"A": [1, 2], "B": [3, 4.5]}) | ||
expected = np.array([[1, 3], [2, 4]], dtype="int64") | ||
result = df.to_numpy(dtype="int64") | ||
tm.assert_numpy_array_equal(result, expected) | ||
|
||
def test_to_numpy_copy(self): | ||
arr = np.random.randn(4, 3) | ||
df = DataFrame(arr) | ||
assert df.values.base is arr | ||
assert df.to_numpy(copy=False).base is arr | ||
assert df.to_numpy(copy=True).base is not arr | ||
|
||
def test_to_numpy_mixed_dtype_to_str(self): | ||
# https://github.com/pandas-dev/pandas/issues/35455 | ||
df = DataFrame([[Timestamp("2020-01-01 00:00:00"), 100.0]]) | ||
result = df.to_numpy(dtype=str) | ||
expected = np.array([["2020-01-01 00:00:00", "100.0"]], dtype=str) | ||
tm.assert_numpy_array_equal(result, expected) |
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
File renamed without changes.
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
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.
shouldn't these be with test_values.py
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.
these tests are for to_numpy. yes the methods are related, but this is the best way to keep the "where are tests for X" unambiguous
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.
ok