Skip to content

TST: Parametrize dtypes tests - test_common.py and test_concat.py #20340

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 2 commits into from
Mar 15, 2018

Conversation

jschendel
Copy link
Member

@jschendel jschendel commented Mar 14, 2018

Parametrized some straightforward dtypes related tests.

Relatively minor changes to test_common.py:

  • mostly just extracted for loops
  • split one test into two separate tests (see code comment)

Made larger changes to test_concat.py:

  • removed the test class in favor of plain functions, since there was only one class in the file
  • combined a few different tests into a single test, since they were all using test procedure
    • removed the check_concat validation function since it's only called once now
    • further parametrized over a for loop previously in the check_concat validation function
  • removed the import pandas as pd in favor of directly importing the necessary classes

object, 'float64', np.object_, np.dtype('object'), 'O',
np.float64, float, np.dtype('float64')])
def test_pandas_dtype_valid(self, dtype):
assert com.pandas_dtype(dtype) == dtype
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this test is actually necessary? Split this off from the test_invalid_dtype_error, as it appears to be testing valid instead of invalid dtypes. Previously this didn't have any type of assert statement; it just called pandas_dtype and the test passed if no error was raised.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this is ok, this is just testing that pandas_dtype doesn't raise on numpy dtypes

valid_list = [object, 'float64', np.object_, np.dtype('object'), 'O',
np.float64, float, np.dtype('float64')]
for dtype in valid_list:
@pytest.mark.parametrize('dtype', [pd.Timestamp, 'pd.Timestamp', list])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you call this box

object, 'float64', np.object_, np.dtype('object'), 'O',
np.float64, float, np.dtype('float64')])
def test_pandas_dtype_valid(self, dtype):
assert com.pandas_dtype(dtype) == dtype
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this is ok, this is just testing that pandas_dtype doesn't raise on numpy dtypes

Index, DatetimeIndex, PeriodIndex, TimedeltaIndex, Series, Period)


# test cases of the form (to_concat, expected)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you make these fixtures? (or just put directly into the parameterize itself)

assert result == set(expected)


# test cases of the form (to_concat, expected)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@jreback jreback added Testing pandas testing functions or related to the test suite Reshaping Concat, Merge/Join, Stack/Unstack, Explode Dtype Conversions Unexpected or buggy dtype conversions labels Mar 14, 2018
@codecov
Copy link

codecov bot commented Mar 14, 2018

Codecov Report

Merging #20340 into master will decrease coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #20340      +/-   ##
==========================================
- Coverage   91.76%   91.73%   -0.03%     
==========================================
  Files         150      150              
  Lines       49151    49151              
==========================================
- Hits        45102    45090      -12     
- Misses       4049     4061      +12
Flag Coverage Δ
#multiple 90.12% <ø> (-0.03%) ⬇️
#single 41.9% <ø> (ø) ⬆️
Impacted Files Coverage Δ
pandas/plotting/_converter.py 65.07% <0%> (-1.74%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3783ccc...8933d34. Read the comment docs.

@jschendel
Copy link
Member Author

made the requested changes

@jreback jreback added this to the 0.23.0 milestone Mar 15, 2018
@jreback jreback merged commit 0f2dfbe into pandas-dev:master Mar 15, 2018
@jreback
Copy link
Contributor

jreback commented Mar 15, 2018

thanks @jschendel

@jschendel jschendel deleted the param-dtypes-tests branch March 15, 2018 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Reshaping Concat, Merge/Join, Stack/Unstack, Explode Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants