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

Illegal Comparisons when handling pandas DataFrame objects #566

Closed
4 tasks done
jeffknaide opened this issue Feb 24, 2021 · 0 comments · Fixed by #553
Closed
4 tasks done

Illegal Comparisons when handling pandas DataFrame objects #566

jeffknaide opened this issue Feb 24, 2021 · 0 comments · Fixed by #553
Labels
bug Something isn't working

Comments

@jeffknaide
Copy link
Contributor

Describe the bug
In several places, the code attempts to check if a node is missing with a comparison + a conditional (eg x = "a" if node == "???" else "b"). This conditional breaks if the node value is a pandas DataFrame, as DataFrames implement additional __bool__ logic that prevents such a conditional (see: https://github.com/pandas-dev/pandas/blob/v1.2.2/pandas/core/generic.py#L1440-L1446).

To Reproduce
creating a DictConfig:

from pandas import DataFrame
from omegaconf import OmegaConf

kwargs = OmegaConf.create({"a": DataFrame()}, flags={"allow_objects": True})

when attempting to set an attribute of an existing config:

from pandas import DataFrame
from omegaconf import OmegaConf

c = OmegaConf.create()
c._set_flag("allow_objects", True)
c.a = DataFrame()

Expected behavior
when running creating DictConfig or setting a new attr, there should simply be an update to the config where the DF object is now included (assuming allow_object flag is set to True).

Additional context

  • OmegaConf version: master branch
  • Python version: 3.7.6
  • Operating system : ubuntu
  • Please provide a minimal repro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant