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

CLN: Removed levels attribute from Categorical #13612

Closed

Conversation

gfyoung
Copy link
Member

@gfyoung gfyoung commented Jul 11, 2016

Deprecated back in 0.15.0 and therefore long overdue. Closes #8376.

@gfyoung gfyoung changed the title Removed levels attribute from Categorical CLN: Removed levels attribute from Categorical Jul 11, 2016
@jorisvandenbossche
Copy link
Member

Looks good to me

cc @JanSchulz

@jorisvandenbossche jorisvandenbossche added Categorical Categorical Data Type Deprecate Functionality to remove in pandas labels Jul 11, 2016
@jorisvandenbossche jorisvandenbossche added this to the 0.19.0 milestone Jul 11, 2016

# TODO: Remove after deprecation period in 2017/ after 0.18
levels = property(fget=_get_levels, fset=_set_levels)

_ordered = None
Copy link
Contributor

Choose a reason for hiding this comment

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

iirc there is some unpick code that we should think about

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO it would be ok to keep the old compat code in the pickle codepaths...

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree with @JanSchulz : I don't think we should remove that code-path right away.

@codecov-io
Copy link

codecov-io commented Jul 11, 2016

Current coverage is 84.38%

Merging #13612 into master will increase coverage by <.01%

@@             master     #13612   diff @@
==========================================
  Files           142        142          
  Lines         51235      51223    -12   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
- Hits          43235      43226     -9   
+ Misses         8000       7997     -3   
  Partials          0          0          

Powered by Codecov. Last updated by c9a27ed...f1254df

@@ -1554,18 +1554,6 @@ def test_deprecated_labels(self):
res = cat.labels
self.assert_numpy_array_equal(res, exp)

def test_deprecated_levels(self):
Copy link
Contributor

@jreback jreback Jul 12, 2016

Choose a reason for hiding this comment

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

no, all of the legacy pickles need to be an EARLIER version of pandas that HAS the .levels in the categorical.

This is not testing anything.

Copy link
Contributor

Choose a reason for hiding this comment

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

in this case create, let's do a different way. create a pickle in 0.18.1 with the levels. save and create create a specific test to read back and validate.

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. Whoops, I'll generate new pickles then.

  2. Wait, but isn't that what the test_pickle tests are for? I'm confused here...

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 what test_pickles does. However a Categorical that has a levels attribute does not exist in old pickles.

Copy link
Member Author

Choose a reason for hiding this comment

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

If you look at the comments in test_categorical.py (which I now understand why they were included), you'll see that in fact the old pickles do have the levels attribute passed in, as far back as test_pickle_v0_14_1 - is a test in 0.18.1 for levels necessary then?

Copy link
Member Author

Choose a reason for hiding this comment

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

@JanSchulz : I agree. @jreback , there is no need to generate pickles with the levels parameter. We already have tests for them that pass in this PR with no issues. I think this is ready to be merged then since the potential backwards compatibility issue isn't actually a problem.

Copy link
Contributor

Choose a reason for hiding this comment

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

@gfyoung your comments indicate you don't understand my point. We don't have tests that have a levels attribute IN A PICKLE. Thus the tests don't test the correct thing, and you cannot assure back-compat.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we do: https://github.com/pydata/pandas/blob/master/pandas/tests/data/categorical_0_14_1.pickle contains a _pickle string. Or do I misunderstand something?

Copy link
Contributor

Choose a reason for hiding this comment

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

ahh @JanSchulz yes I remember now. The issue is that we don't do this with anything else, and therefore they are in the wrong place (they really should have been in the generate_data scripts). ok @gfyoung can you move those 2 test to pandas/io/read_pickle (and the associated data files). Then they will be in the correct place. We do all pickle testing in a centralized place (except for round-tripping, which doesn't require data files).

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@gfyoung gfyoung force-pushed the categorical-levels-remove branch 3 times, most recently from 14e2b74 to e70c9b7 Compare July 14, 2016 04:51
@gfyoung
Copy link
Member Author

gfyoung commented Jul 15, 2016

@jreback , @JanSchulz : relocated those pickle tests for Categorical, and Travis is still happy. Ready to merge if there are no other concerns.

@jreback
Copy link
Contributor

jreback commented Jul 15, 2016

thanks!

@gfyoung gfyoung deleted the categorical-levels-remove branch July 15, 2016 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Categorical Categorical Data Type Deprecate Functionality to remove in pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants