Public api change: rename adata to data and make it positional only
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 598
- Forks
- 121
- Avg merge
- 3d 11h
- Merged PRs (30d)
- 3
Description
Makes sense to me! Make sure to add a
/to the parameter specification to enforce that people aren’t actually using the name.And put the
/after all the “main” parameters if there are more than justdata. Depends on your judgement what a “main” parameters are – it’s often the same list as the mandatory parameters, unless a function has too many mandatory parameters, or multiple mandatory parameters have the same type and the order could be confusing.I think most good APIs have 1–2 positional-only parameters (might have defaults), and some keyword-only parameters that all have defaults. Most functions have zero positional-or-keyword parameters, but for some it makes sense.
e.g.
var_by_distancewould look like this:def var_by_distance( adata: AnnData, groups: str | list[str] | NDArrayA, /, *, cluster_key: str | None = None, ... ) -> ...:whereas
nhood_enrichmentwould look like this, so people can call it either asnhood_enrichment(adata, "k")ornhood_enrichment(adata, cluster_key=..., library_key=...)to clarify which key is which.def nhood_enrichment( data: AnnData | SpatialData, /, cluster_key: str, *, library_key: str | None = None, connectivity_key: str | None = None, ... ) -> ...:
Originally posted by @flying-sheep in https://github.com/scverse/squidpy/issues/1134#issuecomment-4458065013
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by searching the Python source for public functions using adata, beginning with the var_by_distance and nhood_enrichment examples named in the issue. Review which parameters are main versus keyword-only, then consider the work complete when the affected public signatures consistently use positional-only data as specified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend-api-design
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100