示例#1
0
def test_pump_io_cant_set_both_duration_and_ml():
    with pytest.raises(AssertionError):
        add_media(ml=1, duration=1, unit=unit, experiment=exp)
    with pytest.raises(AssertionError):
        add_alt_media(ml=1, duration=1, unit=unit, experiment=exp)
    with pytest.raises(AssertionError):
        remove_waste(ml=1, duration=1, unit=unit, experiment=exp)
示例#2
0
def test_pump_io():
    add_media(ml=0.1, unit=unit, experiment=exp)
    add_alt_media(ml=0.1, unit=unit, experiment=exp)
    remove_waste(ml=0.1, unit=unit, experiment=exp)

    add_media(duration=0.1, unit=unit, experiment=exp)
    add_alt_media(duration=0.1, unit=unit, experiment=exp)
    remove_waste(duration=0.1, unit=unit, experiment=exp)
示例#3
0
    def execute_io_action(self, alt_media_ml=0, media_ml=0, waste_ml=0):
        assert (
            abs(alt_media_ml + media_ml - waste_ml) < 1e-5
        ), f"in order to keep same volume, IO should be equal. {alt_media_ml}, {media_ml}, {waste_ml}"

        max_ = 0.3
        if alt_media_ml > max_:
            self.execute_io_action(
                alt_media_ml=alt_media_ml / 2,
                media_ml=media_ml,
                waste_ml=media_ml + alt_media_ml / 2,
            )
            self.execute_io_action(alt_media_ml=alt_media_ml / 2,
                                   media_ml=0,
                                   waste_ml=alt_media_ml / 2)
        elif media_ml > max_:
            self.execute_io_action(alt_media_ml=0,
                                   media_ml=media_ml / 2,
                                   waste_ml=media_ml / 2)
            self.execute_io_action(
                alt_media_ml=alt_media_ml,
                media_ml=media_ml / 2,
                waste_ml=alt_media_ml + media_ml / 2,
            )
        else:
            if alt_media_ml > 0:
                add_alt_media(
                    ml=alt_media_ml,
                    source_of_event=self.job_name,
                    unit=self.unit,
                    experiment=self.experiment,
                )
                brief_pause(
                )  # allow time for the addition to mix, and reduce the step response that can cause ringing in the output V.
            if media_ml > 0:
                add_media(
                    ml=media_ml,
                    source_of_event=self.job_name,
                    unit=self.unit,
                    experiment=self.experiment,
                )
                brief_pause()
            if waste_ml > 0:
                remove_waste(
                    ml=waste_ml,
                    source_of_event=self.job_name,
                    unit=self.unit,
                    experiment=self.experiment,
                )
                # run remove_waste for an additional few seconds to keep volume constant (determined by the length of the waste tube)
                remove_waste(
                    duration=2,
                    source_of_event=self.job_name,
                    unit=self.unit,
                    experiment=self.experiment,
                )
                brief_pause()
示例#4
0
def test_pump_io() -> None:
    ml = 0.1
    assert ml == add_media(ml=ml, unit=unit, experiment=exp)
    assert ml == add_alt_media(ml=ml, unit=unit, experiment=exp)
    assert ml == remove_waste(ml=ml, unit=unit, experiment=exp)

    ml = 1.0
    assert ml == add_media(duration=ml, unit=unit, experiment=exp)
    assert ml == add_alt_media(duration=ml, unit=unit, experiment=exp)
    assert ml == remove_waste(duration=ml, unit=unit, experiment=exp)
示例#5
0
def test_pump_io_doesnt_allow_negative():
    with pytest.raises(AssertionError):
        add_media(ml=-1, unit=unit, experiment=exp)
    with pytest.raises(AssertionError):
        add_alt_media(ml=-1, unit=unit, experiment=exp)
    with pytest.raises(AssertionError):
        remove_waste(ml=-1, unit=unit, experiment=exp)

    with pytest.raises(AssertionError):
        add_media(duration=-1, unit=unit, experiment=exp)
    with pytest.raises(AssertionError):
        add_alt_media(duration=-1, unit=unit, experiment=exp)
    with pytest.raises(AssertionError):
        remove_waste(duration=-1, unit=unit, experiment=exp)
示例#6
0
    def execute(self):
        vol = add_media(
            ml=self.volume,
            source_of_event=f"{self.job_name}:{self.automation_name}",
            unit=self.unit,
            experiment=self.experiment,
        )
        if vol != self.volume:
            self.logger.warning("under-dosed!")

        return events.AddMediaEvent(f"Added {vol} mL")