Skip to content

Commit

Permalink
shuffle
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Aug 26, 2023
1 parent bef9ec5 commit 2a32efe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- New configuration option `waste_removal_multiplier` to run the waste pump for a different multiplier (default 2), under `[dosing_automation.config]`
- A warning will appear if the reference PD is measuring too much noise.
- added another self-test test to confirm that an aturbid liquid in vial will produce a near 0 signal.
- general improvements to self-test
- New CLI command: `pio clear-cache <cache> <key>` to remove a key from a cache.
- New CLI subcommand `delete` of `pio run od_blank` to remove the current experiment's blank values. This is also exposed in the UI.

Expand Down
24 changes: 12 additions & 12 deletions pioreactor/actions/self_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from time import sleep
from typing import Callable
from typing import cast
from typing import Optional

import click

Expand Down Expand Up @@ -117,17 +118,18 @@ def test_all_positive_correlations_between_pds_and_leds(
TODO: if this exits early, we should turn off the LEDs
"""
from pprint import pformat
from random import shuffle

# better to err on the side of MORE samples than less - it's only a few extra seconds...
# we randomize to reduce effects of temperature
INTENSITIES = list(range(15, 85, 5))
shuffle(INTENSITIES)

INTENSITIES = list(
range(15, 85, 5)
) # better to err on the side of MORE samples than less - it's only a few extra seconds...
current_experiment_name = get_latest_experiment_name()
results: dict[tuple[LedChannel, PdChannel], float] = {}

adc_reader = ADCReader(
channels=ALL_PD_CHANNELS,
dynamic_gain=False,
fake_data=is_testing_env(),
channels=ALL_PD_CHANNELS, dynamic_gain=False, fake_data=is_testing_env(), penalizer=0.0
).setup_adc()

# set all to 0, but use original experiment name, since we indeed are setting them to 0.
Expand Down Expand Up @@ -338,8 +340,6 @@ def test_positive_correlation_between_rpm_and_stirring(
assert is_heating_pcb_present()
assert voltage_in_aux() <= 18.0

current_experiment_name = get_latest_experiment_name()

with local_persistant_storage("stirring_calibration") as cache:
if "linear_v1" in cache:
parameters = loads(cache["linear_v1"])
Expand All @@ -358,7 +358,7 @@ def test_positive_correlation_between_rpm_and_stirring(
end = initial_dc * 0.8

with stirring.Stirrer(
target_rpm=0, unit=unit, experiment=current_experiment_name, rpm_calculator=None
target_rpm=0, unit=unit, experiment=experiment, rpm_calculator=None
) as st, stirring.RpmFromFrequency() as rpm_calc:
rpm_calc.setup()
st.duty_cycle = initial_dc
Expand Down Expand Up @@ -419,8 +419,8 @@ def _run(self, client, logger: Logger, unit: str, experiment_name: str) -> None:


@click.command(name="self_test")
@click.option("-k", help="see pytest's -k argument", type=str, default="")
def click_self_test(k: str) -> int:
@click.option("-k", help="see pytest's -k argument", type=str)
def click_self_test(k: Optional[str]) -> int:
"""
Test the input/output in the Pioreactor
"""
Expand Down Expand Up @@ -463,7 +463,7 @@ def click_self_test(k: str) -> int:
functions_to_test = {
f
for (name, f) in vars(sys.modules[__name__]).items()
if name.startswith("test_") and (k in name)
if name.startswith("test_") and (k in name if k else True)
}

logger.info(f"Starting self-test. Running {len(functions_to_test)} tests.")
Expand Down

0 comments on commit 2a32efe

Please sign in to comment.