single-cell-data / SOMA

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

Rework Experiment and Measurement to be mixins #95

Closed thetorpedodog closed 1 year ago

thetorpedodog commented 1 year ago

Previously Experiment and Measurement were implemented as wrappers around SOMA objects. However, as the complexity of the SOMA interfaces increases (and we want to ensure that they are extensible by implementations), it is clear that they make more sense as mixins.

This follows the inspiration of pathlib, where extra behaviors are specified in a mixin, and a specialization inherits both the implementation class (i.e., a concrete Collection) and the extra behaviors (e.g. Experiment or Measurement).

The parent of the Experiment and Measurement mixins are specified as MutableMappings instead of Collections to avoid an inheritance conflict in the Python interpreter:

TypeError: multiple bases have instance lay-out conflict.