Skip to content

bug #275 resolve#442

Open
samay2504 wants to merge 2 commits intopysal:mainfrom
samay2504:fix/issue-275-g-local-int-dtype
Open

bug #275 resolve#442
samay2504 wants to merge 2 commits intopysal:mainfrom
samay2504:fix/issue-275-g-local-int-dtype

Conversation

@samay2504
Copy link
Copy Markdown
Contributor

@samay2504 samay2504 commented Mar 31, 2026

This PR fixes issue #275 by making G_Local robust to integer and mixed numeric input dtypes that previously triggered a Numba TypingError during 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, verifies G_Local runs successfully after the fix in esda/getisord.py.

Copilot AI review requested due to automatic review settings March 31, 2026 18:22
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 y to a float dtype at G_Local initialization to keep permutation-inference matrix operations dtype-consistent.
  • Refactor the transform validation assertion formatting in _infer_star_and_structure_w.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread esda/getisord.py
island_weight=0,
):
y = np.asarray(y).flatten()
y = np.asarray(y).flatten().astype(float, copy=False)
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment thread esda/getisord.py Outdated
Comment on lines +598 to +601
assert transform.lower() in (
"r",
"b",
), f'Transforms must be binary "b" or row-standardized "r".Recieved: {transform}'
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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}'
)

Copilot uses AI. Check for mistakes.
Comment thread esda/getisord.py Outdated
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.2%. Comparing base (74ca549) to head (189d5b4).

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main    #442   +/-   ##
=====================================
  Coverage   82.2%   82.2%           
=====================================
  Files         27      27           
  Lines       3969    3969           
=====================================
  Hits        3264    3264           
  Misses       705     705           
Files with missing lines Coverage Δ
esda/getisord.py 70.6% <100.0%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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