pyplate.Container
- class Container(name: str, max_volume: str = 'inf L', initial_contents: Iterable[Tuple[Substance, str]] | None = None)[source]
Bases:
objectStores specified quantities of Substances in a vessel with a given maximum volume. Immutable.
- name
Name of the Container.
- contents
A dictionary of Substances to floats denoting how much of each Substance is the Container.
- volume
Current volume held in the Container in storage format.
- max_volume
Maximum volume Container can hold in storage format.
- __init__(name: str, max_volume: str = 'inf L', initial_contents: Iterable[Tuple[Substance, str]] | None = None)[source]
Create a Container.
- Parameters:
name – Name of container
max_volume – Maximum volume that can be stored in the container in mL
initial_contents – (optional) Iterable of tuples of the form (Substance, quantity)
Methods
__init__(name[, max_volume, initial_contents])Create a Container.
create_solution(solute, solvent[, name])Create a solution.
create_solution_from(source, solute, ...[, name])Create a diluted solution from an existing solution or solutions.
dilute(solute, concentration, solvent[, name])Dilutes solute in solution to concentration.
fill_to(solvent, quantity)Fills container with solvent up to quantity.
get_concentration(solute[, units])Get the concentration of solute in the current solution.
Returns: A set of substances present in the container.
get_volume([unit])Get the volume of the container.
Returns: True if any substance in the container is a liquid.
remove([what])Removes substances from Container
transfer(source, destination, quantity)Move quantity ('10 mL', '5 mg') from source to destination container, returning copies of the objects with amounts adjusted accordingly.
- static create_solution(solute: Substance | Iterable[Substance], solvent: Substance | Container, name: str | None = None, **kwargs) Container[source]
Create a solution.
Two out of concentration, quantity, and total_quantity must be specified.
Multiple solutes can be, optionally, provided as a list. Each solute will have the desired concentration or quantity in the final solution.
If one value is specified for concentration or quantity and multiple solutes are provided, the value will be used for all solutes.
- Parameters:
solute – What to dissolve. Can be a single Substance or a list of Substances.
solvent – What to dissolve with. Can be a Substance or a Container.
name – Optional name for new container.
concentration – Desired concentration(s). (‘1 M’, ‘0.1 umol/10 uL’, etc.)
quantity – Desired quantity of solute(s). (‘3 mL’, ‘10 g’)
total_quantity – Desired total quantity. (‘3 mL’, ‘10 g’)
- Returns:
New container with desired solution.
- static create_solution_from(source: Container, solute: Substance, concentration: str, solvent: Substance | Container, quantity: str, name=None) Tuple[Container, Container] | Tuple[Container, Container, Container][source]
Create a diluted solution from an existing solution or solutions.
- Parameters:
source – Solution to dilute.
solute – What to dissolve.
concentration – Desired concentration. (‘1 M’, ‘0.1 umol/10 uL’, etc.)
solvent – What to dissolve with (if it is a Container, it can contain some solute).
quantity – Desired total quantity. (‘3 mL’, ‘10 g’)
name – Optional name for new container.
- Returns:
- Residual from the source container (and possibly the solvent container)
and a new container with the desired solution.
- Raises:
ValueError – If the solution is impossible to create.
- dilute(solute: Substance, concentration: str, solvent: Substance, name=None) Container[source]
Dilutes solute in solution to concentration.
- Parameters:
solute – Substance which is subject to dilution.
concentration – Desired concentration.
solvent – What to dilute with.
name – Optional name for new container.
Returns: A new container containing a solution with the desired concentration of solute.
- fill_to(solvent: Substance, quantity: str) Container[source]
Fills container with solvent up to quantity.
- Parameters:
solvent – Substance to use to fill.
quantity – Desired final quantity in container.
Returns: New Container with desired final quantity
- get_concentration(solute: Substance, units: str = 'M') float[source]
Get the concentration of solute in the current solution.
- Parameters:
solute – Substance interested in.
units – Units to return concentration in, defaults to Molar.
Returns: Concentration
- get_volume(unit: str | None = None) float[source]
Get the volume of the container.
- Parameters:
unit – Unit to return volume in. Defaults to volume_display_unit from config.
Returns: Volume of the container.
- remove(what: Substance | int = 2) Container[source]
Removes substances from Container
- Parameters:
what – What to remove. Can be a type of substance or a specific substance. Defaults to LIQUID.
Returns: New Container with requested substances removed.
- static transfer(source: Container | Plate | PlateSlicer, destination: Container, quantity: str) Tuple[Container | Plate | PlateSlicer, Container][source]
Move quantity (‘10 mL’, ‘5 mg’) from source to destination container, returning copies of the objects with amounts adjusted accordingly.
- Parameters:
source – Container, plate, or slice to transfer from.
destination – Container to transfer to:
quantity – How much to transfer.
- Returns:
A tuple of (T, Container) where T is the type of the source.