Skip to content

Collect tslibs test, organize PeriodIndex tests #19627

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

Closed
wants to merge 10 commits into from

Conversation

jbrockmendel
Copy link
Member

@jbrockmendel jbrockmendel commented Feb 10, 2018

Parametrize a bunch of nested tests.

@@ -933,3 +935,16 @@ def test_datetime64_with_DateOffset(klass, assert_func):
Timestamp('2000-02-29', tz='US/Central')], name='a')
assert_func(result, exp)
assert_func(result2, exp)


@pytest.mark.parametrize('years,months', product([-1, 0, 1], [-2, 0, 2]))
Copy link
Contributor

Choose a reason for hiding this comment

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

If you parametrize years & months separately, pytest will handle the product

i.e. @pytest.mark.parametrize(('years',[-1, 0, 1]), ('months', [-2, 0, 2]))

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.

lots of nice changes. but pls split into smaller prs. move by type (timedelta, period, timestamp & parsing)

@@ -138,6 +138,48 @@ def test_astype_object(self):
tm.assert_index_equal(casted, Index(exp_values, dtype=np.object_))
assert casted.tolist() == exp_values

idx = pd.date_range(start='2013-01-01', periods=4, freq='M',
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 avoid duplication of lots of code and just parameterize over the tz.



def test_to_datetime1():
actual = pd.to_datetime(datetime(2008, 1, 15))
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 add a refernce for this test (e.g. what is it testing)

can you put it near other tests that are similar

@@ -250,6 +250,79 @@ def test_sub_isub(self):
rng -= 1
tm.assert_index_equal(rng, expected)

# ------------------------------------------------------------------
# PeriodIndex.shift is used by __add__ and __sub__
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 parameterize


assert period_asfreq(1, get_freq('U'), get_freq('N'), False) == 1000

def test_period_ordinal_start_values(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

parameterize


def test_period_ordinal_start_values(self):
# information for 1.1.1970
assert period_ordinal(1970, 1, 1, 0, 0, 0, 0, 0, get_freq('A')) == 0
Copy link
Contributor

Choose a reason for hiding this comment

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

same


def test_period_ordinal_week(self):
assert period_ordinal(1970, 1, 4, 0, 0, 0, 0, 0, get_freq('W')) == 1
assert period_ordinal(1970, 1, 5, 0, 0, 0, 0, 0, get_freq('W')) == 2
Copy link
Contributor

Choose a reason for hiding this comment

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

same

assert (result == datetime(2012, 9, 7))


class TestParseISO8601(object):
Copy link
Contributor

Choose a reason for hiding this comment

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

these are conversion tests no? (so separate file). I don't really want much in tslib/test_testlib.py except if it doesnt' fit anywhere else

@jreback jreback added the Testing pandas testing functions or related to the test suite label Feb 10, 2018
@jreback jreback closed this Feb 10, 2018
@jreback
Copy link
Contributor

jreback commented Feb 10, 2018

see comments above

@jbrockmendel
Copy link
Member Author

@maxim-lian good catch; I'll do that in the next draft.

@jbrockmendel jbrockmendel deleted the itests branch February 10, 2018 18:47
jreback pushed a commit that referenced this pull request Feb 11, 2018
harisbal pushed a commit to harisbal/pandas that referenced this pull request Feb 28, 2018
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