diff --git a/changes.d/615.feature b/changes.d/615.feature new file mode 100644 index 00000000..4f4fdfda --- /dev/null +++ b/changes.d/615.feature @@ -0,0 +1 @@ +Support sympy 1.9 diff --git a/qupulse/hardware/awgs/tabor.py b/qupulse/hardware/awgs/tabor.py index 4f57f025..6e661bc0 100644 --- a/qupulse/hardware/awgs/tabor.py +++ b/qupulse/hardware/awgs/tabor.py @@ -12,7 +12,7 @@ from qupulse.utils.types import ChannelID from qupulse._program._loop import Loop, make_compatible -from qupulse.hardware.util import voltage_to_uint16, find_positions +from qupulse.hardware.util import voltage_to_uint16, find_positions, traced from qupulse.hardware.awgs.base import AWG, AWGAmplitudeOffsetHandling from qupulse._program.tabor import TaborSegment, TaborException, TaborProgram, PlottableProgram, TaborSequencing,\ make_combined_wave @@ -21,6 +21,7 @@ __all__ = ['TaborAWGRepresentation', 'TaborChannelPair'] +@traced class TaborAWGRepresentation: def __init__(self, instr_addr=None, paranoia_level=1, external_trigger=False, reset=False, mirror_addresses=()): """ @@ -306,6 +307,7 @@ def selector(channel_pair: 'TaborChannelPair', *args, **kwargs) -> Any: return selector +@traced class TaborChannelPair(AWG): CONFIG_MODE_PARANOIA_LEVEL = None diff --git a/qupulse/hardware/awgs/tektronix.py b/qupulse/hardware/awgs/tektronix.py index 553eb401..801cf2ee 100644 --- a/qupulse/hardware/awgs/tektronix.py +++ b/qupulse/hardware/awgs/tektronix.py @@ -19,7 +19,7 @@ from qupulse._program._loop import Loop, make_compatible from qupulse._program.waveforms import Waveform as QuPulseWaveform from qupulse.utils.types import TimeType -from qupulse.hardware.util import voltage_to_uint16, get_sample_times +from qupulse.hardware.util import voltage_to_uint16, get_sample_times, traced from qupulse.utils import pairwise @@ -238,6 +238,7 @@ def amplitudes(self) -> Tuple[float]: return self._amplitudes +@traced class TektronixAWG(AWG): """Driver for Tektronix AWG object (5000/7000 series). diff --git a/qupulse/hardware/awgs/zihdawg.py b/qupulse/hardware/awgs/zihdawg.py index 990e5205..135deefe 100644 --- a/qupulse/hardware/awgs/zihdawg.py +++ b/qupulse/hardware/awgs/zihdawg.py @@ -24,6 +24,7 @@ from qupulse._program.seqc import HDAWGProgramManager, UserRegister, WaveformFileSystem from qupulse.hardware.awgs.base import AWG, ChannelNotFoundException, AWGAmplitudeOffsetHandling from qupulse.pulses.parameters import ConstantParameter +from qupulse.hardware.util import traced logger = logging.getLogger('qupulse.hdawg') @@ -43,6 +44,7 @@ def valid_fn(*args, **kwargs): return valid_fn +@traced class HDAWGRepresentation: """HDAWGRepresentation represents an HDAWG8 instruments and manages a LabOne data server api session. A data server must be running and the device be discoverable. Channels are per default grouped into pairs.""" @@ -290,6 +292,7 @@ class HDAWGModulationMode(Enum): ADVANCED = 5 # AWG output modulates corresponding sines from modulation carriers. +@traced class HDAWGChannelGroup(AWG): """Represents a channel pair of the Zurich Instruments HDAWG as an independent AWG entity. It represents a set of channels that have to have(hardware enforced) the same control flow and sample rate. diff --git a/qupulse/hardware/dacs/alazar.py b/qupulse/hardware/dacs/alazar.py index 168646e8..6d4b12ab 100644 --- a/qupulse/hardware/dacs/alazar.py +++ b/qupulse/hardware/dacs/alazar.py @@ -14,6 +14,7 @@ from qupulse.utils.types import TimeType from qupulse.hardware.dacs.dac_base import DAC +from qupulse.hardware.util import traced logger = logging.getLogger(__name__) @@ -200,6 +201,7 @@ def __repr__(self): return 'OneBufferPerWindow()' +@traced class AlazarCard(DAC): def __init__(self, card, config: Optional[ScanlineConfiguration]=None): self.__card = card diff --git a/qupulse/hardware/util.py b/qupulse/hardware/util.py index 7508ba5f..365e4766 100644 --- a/qupulse/hardware/util.py +++ b/qupulse/hardware/util.py @@ -3,11 +3,19 @@ import numpy as np +try: + from autologging import traced +except ImportError: + def traced(obj): + """Noop traced that is used if autologging package is not available""" + return obj + from qupulse._program.waveforms import Waveform from qupulse.utils.types import TimeType from qupulse.utils import pairwise -__all__ = ['voltage_to_uint16', 'get_sample_times'] + +__all__ = ['voltage_to_uint16', 'get_sample_times', 'traced'] def voltage_to_uint16(voltage: np.ndarray, output_amplitude: float, output_offset: float, resolution: int) -> np.ndarray: diff --git a/qupulse/utils/sympy.py b/qupulse/utils/sympy.py index 59e13174..e27dc903 100644 --- a/qupulse/utils/sympy.py +++ b/qupulse/utils/sympy.py @@ -60,7 +60,7 @@ def unimplementded(*args, **kwargs): raise NotImplementedError("Not a full dict") for m in vars(dict).keys(): - if not m.startswith('_'): + if not m.startswith('_') and (m not in ('pop',)): setattr(self, m, unimplementded) def __getitem__(self, k) -> sympy.Expr: @@ -78,6 +78,16 @@ def __getitem__(self, k) -> sympy.Expr: self.symbols.add(k) return self.SubscriptionChecker(k) + def pop(self, key, *args, **kwargs): + # this is a workaround for some sympy 1.9 code + if args: + default, = args + elif kwargs: + default, = kwargs.values() + else: + raise KeyError(key) + return default + def __setitem__(self, key, value): raise NotImplementedError("Not a full dict") diff --git a/setup.cfg b/setup.cfg index b954702a..84c0859f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -45,6 +45,7 @@ tabor-instruments = zurich-instruments = zhinst Faster-fractions = gmpy2 tektronix = tek_awg>=0.2.1 +autologging = autologging # sadly not open source for external legal reasons # commented out because pypi does not allow direct dependencies # atsaverage = atsaverage @ git+ssh://git@git.rwth-aachen.de/qutech/cpp-atsaverage.git@master#egg=atsaverage&subdirectory=python_source diff --git a/tests/utils/sympy_tests.py b/tests/utils/sympy_tests.py index e8155721..e02b8945 100644 --- a/tests/utils/sympy_tests.py +++ b/tests/utils/sympy_tests.py @@ -517,7 +517,7 @@ def test_isinstance(self): def test_missing_methods(self): fn = IndexedBasedFinder() - for method in ('pop', 'update', 'get', 'setdefault'): + for method in ('update', 'get', 'setdefault'): with self.assertRaises(NotImplementedError, msg=method): getattr(fn, method)()