hispecdrp.datamodels.mixins

Classes

FiberAttributeProxyMixin()

Mixin that adds fiber-indexed attribute proxy access to a DataModel.

_FiberProxy(model, base)

Proxy returned by model.spec_fib (any attr ending in _fib).

_FiberView(model, fiber)

Proxy returned by model[fiber].

class FiberAttributeProxyMixin[source]

Bases: object

Mixin that adds fiber-indexed attribute proxy access to a DataModel.

Features

  • model.spec_fib[fiber] → model.spec_fib{fiber} (get)

  • model.spec_fib[fiber] = value → model.spec_fib{fiber} = value (set)

  • model[fiber].spec → model.spec_fib{fiber} (get, via fiber view)

  • model[fiber].spec = value → model.spec_fib{fiber} = value (set, via fiber view)

fiber may be an int or str, e.g. 1 or '1'.

Usage

Place the mixin before the base DataModel in the class definition so that its __getattr__ and __setattr__ hooks are resolved first:

class L2Model(FiberAttributeProxyMixin, DataModel): ...
class _FiberProxy(model, base)[source]

Bases: object

Proxy returned by model.spec_fib (any attr ending in _fib).

Supports subscript get/set so that model.spec_fib[fiber] is equivalent to model.spec_fib{fiber}.

class _FiberView(model, fiber)[source]

Bases: object

Proxy returned by model[fiber].

Allows accessing any fiber-indexed extension without the _fib suffix, e.g. model[1].spec is equivalent to model.spec_fib1.