Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: assign() generates KeyError when using read_pd() samples based on min_dist #24

Open
sgsutcliffe opened this issue Feb 17, 2025 · 0 comments · May be fixed by #25
Open

Bug: assign() generates KeyError when using read_pd() samples based on min_dist #24

sgsutcliffe opened this issue Feb 17, 2025 · 0 comments · May be fixed by #25
Assignees

Comments

@sgsutcliffe
Copy link
Contributor

Problem

In the read_pd() function of the dist_reader class there is an option to drop samples based on a minimum distance (i.e. the lowest threshold set for clusters).

           if self.filter:
                if self.min_dist is not None:
                    if d < self.min_dist:
                        continue
                if self.max_dist is not None:
                     if d > self.max_dist:
                        continue

This creates an issue in the assign class when the id is dropped from dist

                            for id in addr_members:
                                addr_dists.append(dists[qid][id])

Which creates a KeyError

Proposed Solution

Not the most efficient, but easy to implement, is to add a conditional statement prior to appending the address:

                            for id in addr_members:
                                if id in dists[qid]: #<--- add conditional statement
                                    addr_dists.append(dists[qid][id])
@sgsutcliffe sgsutcliffe self-assigned this Feb 17, 2025
@sgsutcliffe sgsutcliffe linked a pull request Feb 19, 2025 that will close this issue
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 a pull request may close this issue.

1 participant