-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
numpy ravel with dataframe test GH#26247 #52403
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
Conversation
liang3zy22
commented
Apr 4, 2023
- closes numpy ravel does not work on a list of DataFrames with specified column names #26247 (Replace xxxx with the GitHub issue number)
- Tests added and passed if fixing a bug or adding a new feature
- All code checks passed.
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.
Thanks @liang3zy22 for your PR! this is off to a good start
I just have some comments:
- can we not use random numbers in the test please? let's use explicit input and output
- the test location might not be appropriate -
test_array
is about the pandas array. How about pandas/tests/frame/test_npfuncs.py? - not too keen on single-letter variable names, we can use
arr
please to construct a numpy array?
pandas/tests/arrays/test_array.py
Outdated
|
||
def test_array_ravel_from_df(): | ||
# GH26247 | ||
x = np.random.randn(10, 3) |
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 we not use random numbers in a test (unless necessary) please? let's contruct both the input and the output explicitly
so
arr = np.array([...])
pandas/tests/arrays/test_array.py
Outdated
x = np.random.randn(10, 3) | ||
|
||
result = np.ravel([pd.DataFrame(batch.reshape(1, 3)) for batch in x]) | ||
expected = np.ravel(x) |
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.
likewise, let's construct the output explicitly
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.
Nice, thanks for updating!
The example if quite long now - can we trim it down so the matrix is just 2 rows by 3 columns?
Then we can get this in
Signed-off-by: Liang Yan <[email protected]>
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.
Looks good, thanks @liang3zy22 !
Thanks @liang3zy22 |
Signed-off-by: Liang Yan <[email protected]>