fix: convert StringArray to numpy array in uprate_rent#1489
Open
vahid-ahmadi wants to merge 1 commit intomainfrom
Open
fix: convert StringArray to numpy array in uprate_rent#1489vahid-ahmadi wants to merge 1 commit intomainfrom
vahid-ahmadi wants to merge 1 commit intomainfrom
Conversation
The region.values.astype(str) returns a pandas StringArray which is not hashable and cannot be used with ParameterNodeAtInstant.__getitem__. Converting to np.array() ensures compatibility with the vectorial parameter lookup. Fixes TypeError: unhashable type: 'StringArray' when running microsimulations. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
Summary
uprate_rentwhenregion.values.astype(str)returns a pandasStringArrayinstead of a numpy arrayParameterNodeAtInstant.__getitem__expects anumpy.ndarrayfor vectorial lookup, but pandas StringArray is not hashableProblem
When running microsimulations, the following error occurs:
This happens in
economic_assumptions.pyline 164-165 whereregion.values.astype(str)returns a pandas StringArray which cannot be used as a key in the parameter lookup.CI Test Failures (Unrelated to this PR)
The CI test failures are NOT caused by this PR. They are due to a dependency version conflict that occurred after the last successful main branch CI run.
Evidence:
Root cause:
The CI workflow runs
uv pip install policyengine --systemwhich now pulls in:pandas==3.0.0(newly released)microdf-python==1.1.2This combination is broken -
microdf 1.1.2is incompatible withpandas 3.0.0: