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

Patch pandas.core.dtypes.inference.is_dict_like #141

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

WillDaSilva
Copy link

Pandas thinks all non-atom K objects are dicts, which leads to issues like #133. This PR provides a hacky solution to this problem by overwriting the __code__ attribute of the function Pandas uses for checking if an object is dict-like. Patching the function through safer means (e.g. with unittest.mock) won't work well because the function is imported all over Pandas, and we would have to patch all of them.

Fixes #133

Pandas thinks all non-atom K objects are dicts, which leads to issues
like KxSystems#133. This commit provides a hacky solution to this problem by
overwriting the `__code__` attribute of the function Pandas uses for
checking if an object is dict-like. Patching the function through safer
means (e.g. with `unittest.mock`) won't work well because the function
is imported all over Pandas, and we would have to patch all of them.

Fixes KxSystems#133
@lgtm-com
Copy link

lgtm-com bot commented Jun 11, 2021

This pull request introduces 1 alert when merging 79786e8 into 8c31f19 - view on LGTM.com

new alerts:

  • 1 for Module imports itself

@cmccarthy1
Copy link

@sashkab @abalkin Is this change suitable to go in as a patch release of the interface?

@@ -9,6 +9,9 @@ doc/_build/
src/pyq/version.py
html/

.venv*/
venv*/
Copy link
Contributor

Choose a reason for hiding this comment

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

this doesn't belong here.

Copy link
Author

Choose a reason for hiding this comment

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

Would you rather a separate PR just for this change? The .gitignore should exclude Python virtual environments in some capacity.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't believe venvs belong in code repository. For example, I keep my venvs in the .virtualenvs directory. Adding all possible locations will grow .gitignore dramatically and this is not necessary.

Copy link
Author

Choose a reason for hiding this comment

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

Per-project virtual environments are a widespread practice. You'll find most large Python projects have a few lines in their .gitignore to exclude them. Besides, we don't need to add "all possible locations" - no need to let perfect be the enemy of good. This addition takes care of all of the most common ones in just two lines.

@sashkab
Copy link
Contributor

sashkab commented Jun 29, 2021

@cmccarthy1 I'm leaving this to @abalkin to review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pandas 1.0.3 incompatibility
4 participants