Skip to content

Duplicate and inconsistent implementations of get_analyses_by_coordinate in Studyset #1001

@AbirajKangotra

Description

@AbirajKangotra

Summary

There are two implementations of get_analyses_by_coordinate in the Studyset class with different signatures and behaviors. The latter definition overrides the former, making the first implementation effectively dead code.

Details

The first implementation:

  • Accepts xyz and radius r
  • Uses scipy.spatial.distance.cdist

The second implementation:

  • Accepts xyz with either r (radius) or n (number of nearest analyses)
  • Uses manual Euclidean distance computation
  • Overrides the first definition entirely

This leads to:

  • Dead/unreachable code
  • Potential confusion for contributors and users
  • Inconsistent API design

Proposed Solution

  • Remove the duplicate implementation
  • Keep a single unified method supporting both:
    • radius-based filtering (r)
    • nearest-neighbor selection (n)
  • Add validation to ensure only one of r or n is provided
  • Update docstrings accordingly

Additional Suggestions

  • Add tests for both modes (r and n)
  • Consider deprecating older behavior if needed

Why this matters

This improves:

  • API consistency
  • Code maintainability
  • Developer experience

Happy to open a PR for this if the approach is approved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions