riverine.experiments
====================

.. py:module:: riverine.experiments


Classes
-------

.. autoapisummary::

   riverine.experiments.AbstractLocationType
   riverine.experiments.LocationInfo
   riverine.experiments.LocationDict
   riverine.experiments.Experiment


Functions
---------

.. autoapisummary::

   riverine.experiments._exp_attr_set_reference


Module Contents
---------------

.. py:function:: _exp_attr_set_reference(self, attribute: Any, reference: riverine.references.Reference | None) -> riverine.references.Reference | None

.. py:class:: AbstractLocationType

   .. py:attribute:: __slots__
      :value: ()



   .. py:property:: name
      :abstractmethod:



   .. py:property:: is_echo_source_compatible
      :type: bool

      :abstractmethod:



.. py:class:: LocationInfo

   .. py:attribute:: echo_source_type
      :type:  str | None
      :value: None



   .. py:attribute:: echo_dest_type
      :type:  str | None
      :value: None



   .. py:attribute:: full_location
      :type:  tuple[str, Ellipsis]
      :value: ()



   .. py:attribute:: info
      :type:  dict[str, Any]


   .. py:method:: from_obj(obj) -> LocationInfo
      :classmethod:



.. py:class:: LocationDict(locs: dict[str, LocationInfo | Any])

   .. py:attribute:: _locs
      :type:  dict[str, LocationInfo]


   .. py:method:: from_obj(obj) -> LocationDict
      :classmethod:



   .. py:method:: __getitem__(key: str) -> LocationInfo


   .. py:method:: __setitem__(key: str, value: LocationInfo | Any) -> None


   .. py:method:: __delitem__(key: str) -> None


   .. py:method:: __contains__(key: str) -> bool


   .. py:method:: __iter__() -> Iterator[str]


   .. py:method:: __len__() -> int


   .. py:method:: keys() -> collections.abc.KeysView[str]


   .. py:method:: values() -> collections.abc.ValuesView[LocationInfo]


   .. py:method:: items() -> collections.abc.ItemsView[str, LocationInfo]


   .. py:method:: __repr__() -> str


   .. py:method:: __str__() -> str


   .. py:method:: __eq__(other) -> bool


   .. py:method:: get(key: str, default: Any | None = None) -> LocationInfo | None


.. py:class:: Experiment

   A class collecting many related mixes and components, allowing methods to be run that consider all of them
   together.

   Components can be referenced, and set, by name with [], and can be iterated through.


   .. py:attribute:: __hash__


   .. py:attribute:: components
      :type:  dict[str, riverine.components.AbstractComponent]


   .. py:attribute:: volume_checks
      :type:  bool
      :value: True



   .. py:attribute:: reference
      :type:  riverine.references.Reference | None


   .. py:attribute:: locations
      :type:  LocationDict


   .. py:method:: generate_picklist(_cache_key=None) -> Experiment.generate_picklist.PickList


   .. py:method:: add(component: riverine.components.AbstractComponent, *, check_volumes: bool | None = None, apply_reference: bool = True, check_existing: bool | Literal['equal'] = 'equal') -> Experiment


   .. py:method:: add_mix(mix_or_actions: riverine.mixes.Mix | Sequence[riverine.actions.AbstractAction] | riverine.actions.AbstractAction, name: str = '', test_tube_name: str | None = None, *, fixed_total_volume: riverine.units.DecimalQuantity | str | None = None, fixed_concentration: str | riverine.units.DecimalQuantity | None = None, buffer_name: str = 'Buffer', min_volume: riverine.units.DecimalQuantity | str = Q_('0.5', uL), check_volumes: bool | None = None, apply_reference: bool = True, check_existing: bool | Literal['equal'] = 'equal') -> Experiment

      Add a mix to the experiment, either as a Mix object, or by creating a new Mix.

      Either the first argument should be a Mix, or arguments should be passed as for
      initializing a Mix.

      If check_volumes is True (by default), the mix will be added to the experiment, and
      volumes checked.  If the mix causes a volume usage problem, it will not be added to
      the Experiment, and a VolumeError will be raised.

      If check_existing is True (by default), then a exception is raised if the experiment
      already contains a mix with the name `name`. Otherwise, the existing mix is replaced
      with the new mix.



   .. py:method:: __setitem__(name: str, mix: riverine.components.AbstractComponent) -> None


   .. py:method:: get(key: str, default=None)


   .. py:method:: __getitem__(name: str) -> riverine.components.AbstractComponent


   .. py:method:: __delitem__(name: str) -> None


   .. py:method:: __contains__(name: str) -> bool


   .. py:method:: remove_mix(name: str) -> None

      Remove a mix from the experiment, referenced by name,



   .. py:method:: remove(name: str) -> None

      Remove a mix from the experiment, referenced by name,



   .. py:method:: __len__() -> int


   .. py:method:: __iter__() -> Iterator[riverine.components.AbstractComponent]


   .. py:method:: consumed_and_produced_volumes() -> Mapping[str, Tuple[riverine.units.DecimalQuantity, riverine.units.DecimalQuantity]]


   .. py:method:: check_volumes(showall: bool = False, display: bool = True, raise_error: bool = False) -> str | None

      Check to ensure that consumed volumes are less than made volumes.



   .. py:method:: _unstructure() -> dict[str, Any]

      Create a dict representation of the Experiment.



   .. py:method:: _structure(d: dict[str, Any]) -> Experiment
      :classmethod:


      Create an Experiment from a dict representation.



   .. py:method:: load(filename_or_stream: str | os.PathLike | TextIO) -> Experiment
      :classmethod:


      Load an experiment from a JSON-formatted file created by Experiment.save.



   .. py:method:: resolve_components() -> None

      Resolve string/blank-component components in mixes, searching through the mixes
      in the experiment.  FIXME Add used mixes to the experiment if they are not already there.



   .. py:method:: save(filename_or_stream: str | os.PathLike | TextIO) -> None

      Save an experiment to a JSON-formatted file.

      Tries to store each component/mix only once, with other mixes referencing those components.



   .. py:method:: use_reference(reference: riverine.references.Reference) -> Experiment

      Apply a Reference, in place, to all components in the Experiment.



