single-cell-data / SOMA

A flexible and extensible API for annotated 2D matrix data stored in multiple underlying formats.
MIT License
69 stars 9 forks source link

Add `_Axis.getattr_from` and `_Axis.getitem_from`. #183

Closed thetorpedodog closed 7 months ago

thetorpedodog commented 7 months ago

This aims to eliminate the annoyance (and potential error) of writing

thing = whatever.obs if axis is _Axis.OBS else whatever.var

by letting you say

thing = axis.getattr_from(whatever)

instead.

ebezzi commented 7 months ago

@thetorpedodog merging this PR so that I can use it in https://github.com/single-cell-data/SOMA/pull/179. Thanks!