Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #275 by ensuring esda.getisord.G_Local can accept integer (and mixed numeric) inputs without triggering Numba dtype TypingErrors during conditional randomization.
Changes:
- Cast
yto a float dtype atG_Localinitialization to keep permutation-inference matrix operations dtype-consistent. - Refactor the
transformvalidation assertion formatting in_infer_star_and_structure_w.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| island_weight=0, | ||
| ): | ||
| y = np.asarray(y).flatten() | ||
| y = np.asarray(y).flatten().astype(float, copy=False) |
There was a problem hiding this comment.
The PR description mentions adding a regression test (e.g., esda/tests/test_issue_275.py), but no such file appears in the current changeset/repo. Please add the test to the PR (or update the description) so the dtype regression is covered going forward.
| assert transform.lower() in ( | ||
| "r", | ||
| "b", | ||
| ), f'Transforms must be binary "b" or row-standardized "r".Recieved: {transform}' |
There was a problem hiding this comment.
Avoid using assert for validating user inputs like transform; assertions can be stripped with Python optimizations (-O), which would bypass this check. Prefer raising a ValueError (or TypeError if appropriate) with the same message.
| assert transform.lower() in ( | |
| "r", | |
| "b", | |
| ), f'Transforms must be binary "b" or row-standardized "r".Recieved: {transform}' | |
| if transform.lower() not in ( | |
| "r", | |
| "b", | |
| ): | |
| raise ValueError( | |
| f'Transforms must be binary "b" or row-standardized "r".Recieved: {transform}' | |
| ) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #442 +/- ##
=====================================
Coverage 82.2% 82.2%
=====================================
Files 27 27
Lines 3969 3969
=====================================
Hits 3264 3264
Misses 705 705
🚀 New features to boost your workflow:
|
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This PR fixes issue #275 by making
G_Localrobust to integer and mixed numeric input dtypes that previously triggered a NumbaTypingErrorduring conditional randomization: we now normalize the input array to a float dtype in the local-statistic path so matrix operations used in permutation inference are dtype-consistent, while preserving existing public behavior and outputs for standard float inputs; to prevent regression, verifiesG_Localruns successfully after the fix in esda/getisord.py.