scverse / scverse/scanpy

don’t return dicts

Open
#17 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.6k
Forks
779
Avg merge
1d 4h
Merged PRs (30d)
27

Description

e.g pp.filter_genes_dispersion returns a dict with known keys. if you know the keys, this means you should return an object where you can use attribute access instead. usually the pythonic thing to do in this case is to return a namedtuple.

in this case though, we have

>>> {k: v.shape for k, v in filter_result.items()}
{'dispersions': (173351,),
 'dispersions_norm': (173351,),
 'gene_filter': (173351,),
 'means': (173351,)}

which is a perfect case for a recarray.

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

Start at pp.filter_genes_dispersion and inspect how its dict result and the listed keys are consumed by callers. Determine whether a recarray preserves the current values and access patterns, then update the relevant tests or add coverage for the returned fields; done means the function no longer returns a dict and its consumers still work.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
bioinformatics, data
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.