8000 Keep multi-digit states distinct in sequence matching by antonsoo · Pull Request #262 · pysal/giddy · GitHub
[go: up one dir, main page]

Skip to content

Keep multi-digit states distinct in sequence matching - #262

Closed
antonsoo wants to merge 1 commit into
pysal:mainfrom
antonsoo:fix/unambiguous-sequence-keys
Closed

antonsoo wants to merge 1 commit into
pysal:mainfrom
antonsoo:fix/unambiguous-sequence-keys

Conversation

@antonsoo
Copy link
Copy Markdown

Distinct sequences can have the same deduplication key when states have multiple digits:

from giddy.sequence import Sequence

sequences = [[1, 10], [11, 0]] + [[i, i] for i in range(12)]
print(Sequence(sequences, dist_type="interval").seq_dis_mat[0, 1])

Before: KeyError: (11, 0). After: 20.0.

Both (1, 10) and (11, 0) become "110", so one is discarded before the distance lookup. Separate the encoded states with commas to keep sequence boundaries unambiguous while retaining deduplication.

Add numeric and unequal-length string regressions for interval and arbitrary costs. Full tests pass on current and CI oldest dependencies. Shipped U.S. income trajectories classified into finer groups also agree with an independent edit-distance calculation; previously working matrices remain exact. A regular installed wheel reproduces the corrected results.

@martinfleis
Copy link
Copy Markdown
Member

xref pysal/pointpats#216 (comment)

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

0