Skip to content

Reference paths / accessors #2189

@flying-sheep

Description

@flying-sheep

Please describe your wishes and possible alternatives to achieve the desired result.

This has been attempted in #342 already, and would make a lot of things easier and APIs more generic by default:

I prototyped this functionality with a real-world usecase (reimplementing all Scanpy plotting) here: https://github.com/holoviz-topics/hv-anndata/blob/971789b0e1902ac14ea24b4efcabc894e6d838ec/src/hv_anndata/accessors.py

What we should do differently from the prototype is the holoviews dependency: instead of the ACCESSOR constant, anndata should export a factory that takes an AdPath subclass to implement something like hv-anndata’s current Dimension AdPath:

import holoviews as hv
from anndata.access import AdAc, AdPath

class HvAdPath(AdPath, Dimension):
    def __init__(self, *, __repr, __apply, __axes, __label, **params: object) -> None: ... 
        AdPath.__init__(self, __repr=__repr, __apply=__apply, __axes=__axes, __label=__label)
        label_kw = {} if __label is None else dict(label=__label)
        Dimension.__init__(self, __repr, **params, **label_kw)

A: AdAc[HvAdPath] = AdAc(HvAdPath)

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions