-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
MAINT: Remove np.array_equal calls in tests #18047
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
MAINT: Remove np.array_equal calls in tests #18047
Conversation
A couple of questions going forward:
|
c5b4ada
to
4d21ad1
Compare
this has come up a couple of times, sure I guess that would be ok
no, list comparison is directly handled by assert |
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.
need to add np.array_equal
to the black-list in ci/lint.sh (near the end), we check for using black-listed functions and fail the build.
@@ -22,7 +22,10 @@ | |||
|
|||
def eq_gen_range(kwargs, expected): | |||
rng = generate_range(**kwargs) | |||
assert (np.array_equal(list(rng), 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.
I would remove this function and just directly compare these (only 3 uses)
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.
Done.
expected = {0: ['a', 'd', 'g', 'l'], | ||
1: ['b', 'e', 'h', 'm'], | ||
2: ['c', 'f', 'i', 'n']} | ||
expected = {0: np.array(['a', 'd', 'g', 'l'], dtype=object), |
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 think assert can do this; don't convert to a numpy array just to compare
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 output of Textreader.read
is an array, so would need to convert.
@@ -225,7 +225,7 @@ def test_escapechar(self): | |||
reader = TextReader(StringIO(data), delimiter=',', header=None, | |||
escapechar='\\') | |||
result = reader.read() | |||
expected = {0: ['"hello world"'] * 3} | |||
expected = {0: np.array(['"hello world"'] * 3, dtype=object)} |
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.
same
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.
Same as above
There are many instances of this method being called in the source code...I think it shouldn't be allowed in tests BUT be careful with source code though. |
that line in lint should be
|
e.g.
|
4d21ad1
to
c7d2e38
Compare
Codecov Report
@@ Coverage Diff @@
## master #18047 +/- ##
==========================================
- Coverage 91.25% 91.23% -0.02%
==========================================
Files 163 163
Lines 50115 50114 -1
==========================================
- Hits 45730 45720 -10
- Misses 4385 4394 +9
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #18047 +/- ##
==========================================
- Coverage 91.25% 91.23% -0.03%
==========================================
Files 163 163
Lines 50120 50115 -5
==========================================
- Hits 45737 45721 -16
- Misses 4383 4394 +11
Continue to review full report at Codecov.
|
c7d2e38
to
9adf991
Compare
9adf991
to
902f4e9
Compare
that sounds good @gfyoung thanks! |
(cherry picked from commit 194dbff)
xref pandas-dev#18047 (cherry picked from commit 27bbea7)
(cherry picked from commit 194dbff)
Preferable to use
tm.assert_numpy_array_equal
instead.