Skip to content

TST: start tests for PeriodConverter #9055

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

Conversation

jorisvandenbossche
Copy link
Member

@jreback The tests I started related to PR #9050

@jreback
Copy link
Contributor

jreback commented Dec 11, 2014

b69b9d3 (obviously you have more)

@jorisvandenbossche
Copy link
Member Author

yep, I saw that. But I thought to add it both as a test for PeriodConverter (which then seemed to not yet exist), and as a plotting test (but only came around to the first one yesterday, and you already did the second).

@jreback jreback added Period Period data type Visualization plotting labels Dec 12, 2014
@jreback jreback added this to the 0.16.0 milestone Dec 12, 2014
@jreback
Copy link
Contributor

jreback commented Dec 12, 2014

@jorisvandenbossche thought you had merged this, looks ok

@jorisvandenbossche
Copy link
Member Author

there are two parts skipped for now in this PR:

  • the datetime64 part is commented out -> there is already an issue about that: ENH: Period to accept datetime64 value? #9054
  • the unicode test (test_convert_accepts_unicode) is failing, so I was skipping it for now (I copied the test from DatetimeConverter): @jreback this is something that should work?

raise nose.SkipTest("PeriodConverter does not yet handle unicode")
r1 = self.pc.convert("2012-1-1", None, self.axis)
r2 = self.pc.convert(u("2012-1-1"), None, self.axis)
self.assert_equal(r1, r2, "PeriodConverter.convert should accept unicode")
Copy link
Contributor

Choose a reason for hiding this comment

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

Never used PeriodConverter but the undelrying supports, so maybe just a small issue

In [1]: pd.Timestamp(u'20121201')
Out[1]: Timestamp('2012-12-01 00:00:00')

In [2]: pd.Period(u'20121201',freq='D')
Out[2]: Period('2012-12-01', 'D')

Copy link
Member Author

Choose a reason for hiding this comment

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

It is actually a quite simple reason. From https://github.com/pydata/pandas/blob/master/pandas/tseries/converter.py#L112:

valid_types = (str, datetime, Period, pydt.date, pydt.time)
if isinstance(values, valid_types):
....

here of course testing for str does not work for unicode

I will add this

Copy link
Member Author

Choose a reason for hiding this comment

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

I just have to use pd.compat.string_types instead of str?

Copy link
Contributor

Choose a reason for hiding this comment

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

yep

jorisvandenbossche added a commit that referenced this pull request Dec 12, 2014
@jorisvandenbossche jorisvandenbossche merged commit 722fc77 into pandas-dev:master Dec 12, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Period Period data type Visualization plotting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants