Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
h (object)
"""
if isinstance(handle, str):
try:
istr, pstr = handle.split('.')
except Exception as ex:
# probably legacy code
istr = handle
pstr = 'amplitude'
warnings.warn('incorrect format for instrument+parameter handle %s' % (handle,))
else:
istr, pstr = handle
if isinstance(istr, str):
instrument = qcodes.Instrument.find_instrument(istr)
else:
instrument = istr
if isinstance(pstr, int):
pstr = 'channel_%d' % pstr
param = getattr(instrument, pstr)
return instrument, param
"""
if isinstance(instr, (tuple, list)):
# assume the tuple is (instrument, channel)
instr = instr[0]
if isinstance(instr, Instrument):
return instr
if isinstance(instr, AcquisitionScopeInterface):
return instr
if not isinstance(instr, str):
raise Exception('could not find instrument %s' % str(instr))
try:
ref = Instrument.find_instrument(instr)
return ref
except:
pass
if station is not None:
if instr in station.components:
ref = station.components[instr]
return ref
raise Exception('could not find instrument %s' % str(instr))