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

Test evaluate_condition #634

Merged

Conversation

albertvillanova
Copy link
Member

Test evaluate_condition.

Copy link
Collaborator

@aymeric-roucher aymeric-roucher left a comment

Choose a reason for hiding this comment

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

Thank you @albertvillanova !

@albertvillanova
Copy link
Member Author

albertvillanova commented Feb 13, 2025

While implementing the tests, I discovered this code line in evaluate_condition:

return result if isinstance(result, (bool, pd.Series)) else result.all()

  • Why pd.Series is there?
  • Why the call to .all()?

I don't understand these two.

CC: @aymeric-roucher

@aymeric-roucher
Copy link
Collaborator

@albertvillanova the specific handling of pd.Series is made to handle df selection in pandas with df.loc[df["column"] == 2]
In that case the equality test df["column"] == 2should not return a boolean but a pandas.Series of the result (like pd.Series([True, True, False, True, ...])).
The .all() is here to test that all comparators in the list are True.

@aymeric-roucher
Copy link
Collaborator

By the way testing pandas Series indexing would be a good regression test!

@albertvillanova
Copy link
Member Author

@aymeric-roucher I am working on additional tests. But I need to understand the expected behavior.

However, I don't understand the .all case: list in Python does not have an .all method. Which object type is result in this case?Could you give me an example for this case, where we want to call the .all method?

@albertvillanova
Copy link
Member Author

I'm merging this PR and opening another to fix evaluate_condition on non-boolean results.

@albertvillanova albertvillanova merged commit cfe599c into huggingface:main Feb 13, 2025
3 checks passed
@aymeric-roucher
Copy link
Collaborator

@albertvillanova I don't remember the precise case for which I originally added .all()! Thus feel free to remove it.

@albertvillanova
Copy link
Member Author

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.

2 participants