Skip to content
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

TST/CLN: series.duplicated; parametrisation; fix warning #21899

Merged
merged 7 commits into from
Jul 16, 2018

Conversation

h-vetinari
Copy link
Contributor

@h-vetinari h-vetinari commented Jul 13, 2018

Splitting up #21645

Added tests for duplicated, parametrized two tests for drop_duplicates, fixed a warning from #21614.

@codecov
Copy link

codecov bot commented Jul 14, 2018

Codecov Report

Merging #21899 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #21899   +/-   ##
=======================================
  Coverage   91.96%   91.96%           
=======================================
  Files         166      166           
  Lines       50323    50323           
=======================================
  Hits        46281    46281           
  Misses       4042     4042
Flag Coverage Δ
#multiple 90.36% <ø> (ø) ⬆️
#single 42.22% <ø> (-0.01%) ⬇️

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 2b51c96...e640040. Read the comment docs.

('last', Series([False, True, True, False, False, False, False])),
(False, Series([False, True, True, False, True, True, False]))
])
@pytest.mark.parametrize('npdtype', ['int_', 'uint', 'float_', 'unicode_'])
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 use the fixtures defined in pandas/conftest for the dtypes cc @gfyoung

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jreback
I tried

@pytest.mark.parametrize('npdtype', [any_int_dtype, float_dtype, string_dtype])

but pytest can't feed fixtures into parametrisation, see pytest-dev/pytest#349.

Not sure how to do this - separate tests?

Copy link
Contributor

Choose a reason for hiding this comment

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

you simply create a composite fixture

@jreback jreback added the Testing pandas testing functions or related to the test suite label Jul 14, 2018
@jreback jreback added this to the 0.24.0 milestone Jul 14, 2018
@jreback
Copy link
Contributor

jreback commented Jul 14, 2018

needs a rebase

ALL_REAL_DTYPES = FLOAT_DTYPES + ALL_INT_DTYPES
ALL_NUMPY_DTYPES = ALL_REAL_DTYPES + STRING_DTYPES + COMPLEX_DTYPES


Copy link
Member

Choose a reason for hiding this comment

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

Make sure that these lists aren't duplicated in the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gfyoung, what do you mean? I removed ALL_REAL_DTYPES from above and brought it closer to where it's used. Or do you just want one block of all-caps definitions?

Copy link
Member

Choose a reason for hiding this comment

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

One block of all-caps definitions and use it everywhere in the file. For example, search for :

float, "float32", "float64"

in your version of conftest.py . You'll see it exists twice in the file.

Copy link
Contributor

Choose a reason for hiding this comment

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

pls put these with the other definitions

('first', Series([False, False, False, False, True, True, False])),
('last', Series([False, True, True, False, False, False, False])),
(False, Series([False, True, True, False, True, True, False]))
])
Copy link
Contributor

Choose a reason for hiding this comment

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

either use 2 classes for test definitions or don’t use them (preferred)

Copy link
Contributor

Choose a reason for hiding this comment

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

same for frame

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Classes of tests? I just wrote them in the same manner as in test_analytics and then transferred them here. You want me to get rid of TestSeriesDuplicates and do class-less tests - do I get that correctly?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes that is the old format is much less readable

we only use classes if they r logical separations

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

for new modules we like to clean things up to conform

@@ -0,0 +1,145 @@
# coding=utf-8
# pylint: disable-msg=E1101,W0612
Copy link
Contributor

Choose a reason for hiding this comment

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

what are you disabling?

import pytest

import numpy as np
import pandas as pd
Copy link
Contributor

Choose a reason for hiding this comment

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

don’t import pd, directly import instead

from pandas import Series

from pandas.util.testing import assert_series_equal
import pandas.util.testing as tm
Copy link
Contributor

Choose a reason for hiding this comment

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

use tm; don’t import assert_series_equal

@h-vetinari
Copy link
Contributor Author

@jreback All just left-overs from the previous module. Hopefully converging on a clean module soon... ;-)

@jreback
Copy link
Contributor

jreback commented Jul 14, 2018

@h-vetinari absolutely - is just easier to fix when exracting things and make nice and clean

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

can u do the same for frame? (unique and duplicates)

@@ -248,7 +248,19 @@ def tz_aware_fixture(request):
return request.param


@pytest.fixture(params=[str, 'str', 'U'])
UNSIGNED_INT_DTYPES = ["uint8", "uint16", "uint32", "uint64"]
SIGNED_INT_DTYPES = [int, "int8", "int16", "int32", "int64"]
Copy link
Contributor

Choose a reason for hiding this comment

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

@gfyoung this is ok? it follows our existing pattern?

Copy link
Contributor Author

@h-vetinari h-vetinari Jul 14, 2018

Choose a reason for hiding this comment

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

@jreback @gfyoung I only added COMPLEX_DTYPES, STRING_DTYPES (which was just giving names to existing collections) and ALL_NUMPY_DTYPES - the rest was just reordering.


import pytest

import numpy as np
Copy link
Contributor

Choose a reason for hiding this comment

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

you can remove space between pandas imports

@h-vetinari
Copy link
Contributor Author

h-vetinari commented Jul 14, 2018

can u do the same for frame? (unique and duplicates)

@jreback I did the same for frame in #21898

@h-vetinari
Copy link
Contributor Author

@jreback Actually, did the same for #21900 as well - e.g. replace pd. with direct imports

@jreback jreback merged commit 55cbd7d into pandas-dev:master Jul 16, 2018
@jreback
Copy link
Contributor

jreback commented Jul 16, 2018

thanks @h-vetinari

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants