Skip to content

Commit

Permalink
Merge branch 'master' into issues/612_floor_sum_evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
terrorfisch committed Nov 15, 2021
2 parents 9e170e6 + 9589aae commit 1821d67
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 5 deletions.
1 change: 1 addition & 0 deletions changes.d/615.feature
@@ -0,0 +1 @@
Support sympy 1.9
4 changes: 3 additions & 1 deletion qupulse/hardware/awgs/tabor.py
Expand Up @@ -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
Expand All @@ -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=()):
"""
Expand Down Expand Up @@ -306,6 +307,7 @@ def selector(channel_pair: 'TaborChannelPair', *args, **kwargs) -> Any:
return selector


@traced
class TaborChannelPair(AWG):
CONFIG_MODE_PARANOIA_LEVEL = None

Expand Down
3 changes: 2 additions & 1 deletion qupulse/hardware/awgs/tektronix.py
Expand Up @@ -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


Expand Down Expand Up @@ -238,6 +238,7 @@ def amplitudes(self) -> Tuple[float]:
return self._amplitudes


@traced
class TektronixAWG(AWG):
"""Driver for Tektronix AWG object (5000/7000 series).
Expand Down
3 changes: 3 additions & 0 deletions qupulse/hardware/awgs/zihdawg.py
Expand Up @@ -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')
Expand All @@ -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."""
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions qupulse/hardware/dacs/alazar.py
Expand Up @@ -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__)
Expand Down Expand Up @@ -200,6 +201,7 @@ def __repr__(self):
return 'OneBufferPerWindow()'


@traced
class AlazarCard(DAC):
def __init__(self, card, config: Optional[ScanlineConfiguration]=None):
self.__card = card
Expand Down
10 changes: 9 additions & 1 deletion qupulse/hardware/util.py
Expand Up @@ -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:
Expand Down
12 changes: 11 additions & 1 deletion qupulse/utils/sympy.py
Expand Up @@ -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:
Expand All @@ -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")

Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/sympy_tests.py
Expand Up @@ -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)()

Expand Down

0 comments on commit 1821d67

Please sign in to comment.