Fix local_score_BDeu KeyError on pandas >= 2.0#267
Merged
Conversation
local_score_BDeu groups by a single parent column and calls GroupBy.get_group((ij,)). On pandas >= 2.0 a single grouper expects the scalar key, so the 1-tuple raises KeyError — making GES with score_func='local_score_BDeu' unusable on any current pandas (the bug is in the latest release 0.1.4.7 and on main). Try the scalar key first and fall back to the 1-tuple form, so BDeu works on both old and new pandas. The resulting scores match a direct boolean-mask computation, and tests/TestGES.py::test_ges_load_discrete_10_with_local_score_BDeu runs to completion.
kunwuz
self-requested a review
June 20, 2026 05:27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
local_score_BDeu groups by a single parent column and calls GroupBy.get_group((ij,)). On pandas >= 2.0 a single grouper expects the scalar key, so the 1-tuple raises KeyError — making GES with score_func='local_score_BDeu' unusable on any current pandas (the bug is in the latest release 0.1.4.7 and on main).
Try the scalar key first and fall back to the 1-tuple form, so BDeu works on both old and new pandas. The resulting scores match a direct boolean-mask computation, and tests/TestGES.py::test_ges_load_discrete_10_with_local_score_BDeu runs to completion.