lmcinnes / lmcinnes/umap

non_zero_dists might be size 0

Open
#284 15 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0.4
Dominant language
Python
Stars
8.3k
Forks
871
Avg merge
1d 13h
Merged PRs (30d)
5

Description

This does not seem to be an issue when the function is annotated with

@numba.njit(
    fastmath=True
) 

But when removing it, it will sometimes throw:

rho[i] = interpolation * non_zero_dists[0]
IndexError: index 0 is out of bounds for axis 0 with size 0

This happens when non_zero_dists = ith_distances[ith_distances > 0.0] will return no indices for numpy to select.
Example: 2 points, n=2, local_connectivity=0.0

https://github.com/lmcinnes/umap/blob/d5d995625b5cfe55430771e4ec2f044533da7b4c/umap/umap_.py#L118

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open umap/umap_.py around line 118 and inspect how ith_distances is filtered before non_zero_dists[0] is accessed. Reproduce the failure with 2 points, n=2, and local_connectivity=0.0. Done means this input no longer raises IndexError while existing behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.