Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed tests. #185

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ipython_startup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import time
import logging
import time

import databroker # noqa: F401
import matplotlib.pyplot as plt # noqa: F401
from bluesky import RunEngine # noqa: F401
from bluesky import suspenders # noqa: F401
from bluesky import plan_stubs as bps # noqa: F401
from bluesky import plans as bp # noqa: F401
from bluesky import suspenders # noqa: F401
from bluesky.callbacks.best_effort import BestEffortCallback # noqa: F401
from bluesky.simulators import summarize_plan # noqa: F401

Expand Down
1 change: 0 additions & 1 deletion src/haven/instrument/energy_positioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from .._iconfig import load_config
from .device import aload_devices, await_for_connection
from .instrument_registry import registry
from .monochromator import IDTracking, Monochromator

log = logging.getLogger(__name__)
Expand Down
1 change: 0 additions & 1 deletion src/haven/instrument/ion_chamber.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from .. import exceptions
from .._iconfig import load_config
from .device import aload_devices, await_for_connection, make_device
from .instrument_registry import registry
from .labjack import AnalogInput
from .scaler_triggered import ScalerSignalRO, ScalerTriggered

Expand Down
10 changes: 7 additions & 3 deletions src/haven/instrument/power_supply.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from ophyd import FormattedComponent as FCpt

from .._iconfig import load_config
from .device import aload_devices, await_for_connection
from .instrument_registry import registry
from .device import aload_devices, await_for_connection, make_device

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -60,13 +59,18 @@ def load_power_supply_coros(config=None):
config = load_config()
# Determine if any power supplies are available
ps_configs = config.get("power_supply", {})
from pprint import pprint

pprint(ps_configs)
for name, ps_config in ps_configs.items():
# Do it once for each channel
for ch_num in range(1, ps_config["n_channels"] + 1):
yield make_power_supply_device(
yield make_device(
NHQ203MChannel,
name=f"{name}_ch{ch_num}",
prefix=ps_config["prefix"],
ch_num=ch_num,
labels={"power_supplies"},
)


Expand Down
1 change: 0 additions & 1 deletion src/haven/instrument/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from .._iconfig import load_config
from .device import aload_devices, make_device
from .instrument_registry import registry

__all__ = ["XYStage", "load_stages"]

Expand Down
9 changes: 6 additions & 3 deletions src/haven/tests/test_ion_chamber.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def test_amps_signal(sim_ion_chamber):
# Set the necessary dependent signals
chamber.counts.sim_put(int(0.13e7)) # 1.3V
chamber.clock_ticks.sim_put(1e7) # 10 MHz clock
chamber.preamp.gain.put(1 / 2e-5) # 20 µA/V to V/A
chamber.preamp.sensitivity_value.put(4) # "20"
chamber.preamp.sensitivity_unit.put(2) # "µA/V"
# Make sure it ignores the offset if it's off
chamber.preamp.offset_on.put("OFF")
chamber.preamp.offset_value.put("2") # 2
Expand All @@ -98,7 +99,8 @@ def test_amps_signal_with_offset(sim_ion_chamber):
# Set the necessary dependent signals
chamber.counts.sim_put(int(0.13e7)) # 1.3V
chamber.clock_ticks.sim_put(1e7) # 10 MHz clock
chamber.preamp.gain.put(1 / 2e-5) # 20 µA/V to V/A
chamber.preamp.sensitivity_value.put(4) # "20"
chamber.preamp.sensitivity_unit.put(2) # "µA/V"
chamber.preamp.offset_on.put("ON")
chamber.preamp.offset_sign.put("-")
chamber.preamp.offset_value.put("2") # 2
Expand All @@ -115,7 +117,8 @@ def test_voltmeter_amps_signal(sim_ion_chamber):
chamber = sim_ion_chamber
# Set the necessary dependent signals
chamber.voltmeter.volts.sim_put(1.3) # 1.3V
chamber.preamp.gain.put(1 / 2e-5) # 20 µA/V to V/A
chamber.preamp.sensitivity_value.put(4) # "20"
chamber.preamp.sensitivity_unit.put(2) # "µA/V"
# Make sure it ignores the offset if it's off
chamber.preamp.offset_on.put("OFF")
chamber.preamp.offset_value.put("2") # 2
Expand Down
7 changes: 1 addition & 6 deletions src/haven/tests/test_power_supply.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
from unittest import mock

from haven.instrument import power_supply


def test_load_power_supplies(sim_registry, monkeypatch):
monkeypatch.setattr(power_supply, "await_for_connection", mock.AsyncMock())
def test_load_power_supplies(sim_registry):
power_supply.load_power_supplies()
# Test that the device has the right configuration
devices = list(sim_registry.findall(label="power_supplies"))
assert len(devices) == 2 # 2 channels on the device
device = devices[0]
assert "NHQ01_ch" in device.name
pv_names = [d.potential.pvname for d in devices]
assert "ps_ioc:NHQ01:Volt2_rbv" in pv_names


# -----------------------------------------------------------------------------
Expand Down