Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 31, 2024
1 parent 98a61e1 commit 18de6a2
Show file tree
Hide file tree
Showing 9 changed files with 690 additions and 642 deletions.
8 changes: 6 additions & 2 deletions src/examples/buffered_dummy_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@
from qcodes.station import Station

from qumada.instrument.buffered_instruments import BufferedDummyDMM as DummyDmm
from qumada.instrument.buffers.buffer import map_triggers, save_trigger_mapping, load_trigger_mapping
from qumada.instrument.buffers.buffer import (
load_trigger_mapping,
map_triggers,
save_trigger_mapping,
)
from qumada.instrument.custom_drivers.Dummies.dummy_dac import DummyDac
from qumada.instrument.mapping import (
DUMMY_DMM_MAPPING,
Expand Down Expand Up @@ -114,7 +118,7 @@
)

map_terminals_gui(station.components, script.gate_parameters)
map_triggers(station.components, path = r"C:\Users\till3\Documents\PythonScripts\tm.json")
map_triggers(station.components, path=r"C:\Users\till3\Documents\PythonScripts\tm.json")

# %% Run measurement
script.run()
29 changes: 13 additions & 16 deletions src/qumada/instrument/buffers/buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

from __future__ import annotations

import logging
from abc import ABC, abstractmethod
from collections.abc import Mapping
from typing import Any
Expand All @@ -28,7 +29,6 @@
from qcodes.metadatable import Metadatable
from qcodes.parameters import Parameter

import logging
logger = logging.getLogger(__name__)

import json
Expand Down Expand Up @@ -78,7 +78,7 @@ def map_buffers(
print("Available trigger inputs:")
print("[0]: None")
for idx, trigger in enumerate(buffer.AVAILABLE_TRIGGERS, 1):
print(f"[{idx}]: {trigger}")
print(f"[{idx}]: {trigger}")
chosen = int(input(f"Choose the trigger input for {instrument.name}: "))
if chosen == 0:
trigger = None
Expand Down Expand Up @@ -120,12 +120,12 @@ def _map_triggers(
def map_triggers(
components: Mapping[Any, Metadatable],
skip_mapped=True,
path: None|str=None,
path: None | str = None,
**kwargs,
) -> None:
"""
Maps the triggers of triggerable or bufferable components.
Ignores already mapped triggers by default.
Maps the triggers of triggerable or bufferable components.
Ignores already mapped triggers by default.
Parameters
----------
Expand All @@ -136,7 +136,7 @@ def map_triggers(
buffered instruments.
TODO: Remove!
gate_parameters : Mapping[Any, Mapping[Any, Parameter] | Parameter]
Parameters of measurement script/device. Currently only required for
Parameters of measurement script/device. Currently only required for
buffered instruments.
TODO: Remove!
skip_mapped : Bool, optional
Expand All @@ -158,20 +158,16 @@ def map_triggers(
skip_mapped,
**kwargs,
)
_map_triggers(
components,
skip_mapped,
**kwargs
)

_map_triggers(components, skip_mapped, **kwargs)


def save_trigger_mapping(components: Mapping[Any, Metadatable], path: str):
"""
Saves mapped triggers from components to json file.
Components should be station.components, path is the path to the file.
"""
trigger_dict = {}
triggered_instruments = filter(
lambda x: any((is_triggerable(x), is_bufferable(x))), components.values())
triggered_instruments = filter(lambda x: any((is_triggerable(x), is_bufferable(x))), components.values())
for instrument in triggered_instruments:
try:
trigger_dict[instrument.full_name] = instrument._qumada_mapping.trigger_in
Expand All @@ -180,6 +176,7 @@ def save_trigger_mapping(components: Mapping[Any, Metadatable], path: str):
with open(path, mode="w") as file:
json.dump(trigger_dict, file)


def load_trigger_mapping(components: Mapping[Any, Metadatable], path: str):
"""
Loads json file with trigger mappings and tries to apply them to instruments
Expand All @@ -195,8 +192,8 @@ def load_trigger_mapping(components: Mapping[Any, Metadatable], path: str):
instrument._qumada_buffer.trigger = trigger
elif is_triggerable(instrument) is True:
instrument._qumada_mapping.trigger_in = trigger


class Buffer(ABC):
"""Base class for a general buffer interface for an instrument."""

Expand Down
Loading

0 comments on commit 18de6a2

Please sign in to comment.