Skip to content

BUG: make conftest._cython_table deterministic for Python<3.6 #22157

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 1 commit into from
Aug 20, 2018

Conversation

topper-123
Copy link
Contributor

@topper-123 topper-123 commented Aug 1, 2018

Closes a bug for Python < 3.6 where xdist gets non-deterministic input because of random dict ordering for Python < 3.6.

See #22156 for details.

@topper-123
Copy link
Contributor Author

Travis failure is unrelated. Was in pandas/tests/plotting/test_deprecated.py:51:

and message

E AssertionError: Caused unexpected warning(s): [('RuntimeWarning', RuntimeWarning('invalid value encountered in equal',), '/home/travis/miniconda3/envs/pandas/lib/python2.7/site-packages/numpy/core/numeric.py', 2367)].

@jreback jreback added the Testing pandas testing functions or related to the test suite label Aug 1, 2018
@codecov
Copy link

codecov bot commented Aug 1, 2018

Codecov Report

Merging #22157 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #22157   +/-   ##
=======================================
  Coverage   92.08%   92.08%           
=======================================
  Files         169      169           
  Lines       50694    50694           
=======================================
  Hits        46682    46682           
  Misses       4012     4012
Flag Coverage Δ
#multiple 90.49% <100%> (ø) ⬆️
#single 42.34% <100%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/base.py 96.92% <100%> (ø) ⬆️

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 0370740...5b28029. Read the comment docs.

_cython_table = sorted(((key, value) for key, value in
pd.core.base.SelectionMixin._cython_table.items()),
key=lambda x: x[0].__name__)
# manual sorting as dicts in py<3.6 have random order, which xdist doesn't like
Copy link
Contributor

Choose a reason for hiding this comment

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

where does this fail currently? the exact ordering doesn't matter, only that it is deterministic

Copy link
Member

Choose a reason for hiding this comment

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

I’m guessing it’s related to this:
https://travis-ci.org/pandas-dev/pandas/jobs/411841573

Copy link
Contributor

Choose a reason for hiding this comment

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

there was another push after PR

i have never seen this repeat

Copy link
Contributor

Choose a reason for hiding this comment

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

let's solve this entire problem, by just changing _cython_table (and the other _tables) to OrderedDict

@topper-123
Copy link
Contributor Author

hmm, I swear I saw this, but ok, I'll close this PR. If the issue (re-)appears, I can just do a PR then.

@topper-123 topper-123 closed this Aug 9, 2018
@topper-123 topper-123 reopened this Aug 9, 2018
@topper-123
Copy link
Contributor Author

Just saw the reference from #21902.

@h-vetinari, can you conform if you saw the same issue in your PR that I'm raporting in #22156?

@h-vetinari
Copy link
Contributor

Hey @topper-123, i definitely saw this issue at least 2-3 times in the 3.5 Travis build for several PRs. It's real. ;)

@h-vetinari
Copy link
Contributor

Since I rebased #21902, the Travis info is not (easily) available anymore, but I posted an extract there. It was always the same test (exactly related to this issue), so I'm confident about that.

@h-vetinari
Copy link
Contributor

I went through the travis log and looked for some of my old failed jobs. Here's some more occurrences (in each case, it was the only fail out of the required travis builds):
https://travis-ci.org/pandas-dev/pandas/jobs/412363050
https://travis-ci.org/pandas-dev/pandas/jobs/412369259
https://travis-ci.org/pandas-dev/pandas/jobs/413341494

All these are less than 4 days old, so in particular, after the comment from @jreback:

there was another push after PR
i have never seen this repeat

_cython_table = sorted(((key, value) for key, value in
pd.core.base.SelectionMixin._cython_table.items()),
key=lambda x: x[0].__name__)
# manual sorting as dicts in py<3.6 have random order, which xdist doesn't like
Copy link
Contributor

Choose a reason for hiding this comment

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

let's solve this entire problem, by just changing _cython_table (and the other _tables) to OrderedDict

@topper-123 topper-123 force-pushed the cython_table_bug_fix_II branch from c385c99 to 5b28029 Compare August 11, 2018 15:31
@topper-123
Copy link
Contributor Author

Ok, I've made _cython_table and _builtin_table OrderedDicts, which solves the issue. Nice solution.

@topper-123
Copy link
Contributor Author

Is this ok?

@topper-123
Copy link
Contributor Author

A bit odd this bug first shows up and isn't showing up again. Maybe we saw something else?

I'll wait a few days and if this isn't showing again, I can close this PR.

@jreback jreback added this to the 0.24.0 milestone Aug 20, 2018
@jreback jreback merged commit 8d4c7fb into pandas-dev:master Aug 20, 2018
@jreback
Copy link
Contributor

jreback commented Aug 20, 2018

thanks @topper-123 I like this a lot better

@topper-123 topper-123 deleted the cython_table_bug_fix_II branch September 20, 2018 21:12
Sup3rGeo pushed a commit to Sup3rGeo/pandas that referenced this pull request Oct 1, 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.

4 participants