Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _compute_diff_prop(self, k, j, epsilon):
"""
Calculate the propagator from the current point to a trial point
a distance 'epsilon' (change in amplitude)
in the direction the given control j in timeslot k
Returns the propagator
"""
raise errors.UsageError("Not implemented in the baseclass."
" Choose a subclass")
def gen_pulse(self):
"""
returns the pulse as an array of vales for each timeslot
Must be implemented by subclass
"""
# must be implemented by subclass
raise errors.UsageError(
"No method defined for generating a pulse. "
" Suspect base class was used where sub class should have been")
def _init_phase_option(self, value):
self._phase_option = value
if value == 'PSU':
self.fid_norm_func = self.normalize_PSU
self.grad_norm_func = self.normalize_gradient_PSU
elif value == 'SU':
self.fid_norm_func = self.normalize_SU
self.grad_norm_func = self.normalize_gradient_SU
elif value is None:
raise errors.UsageError("phase_option cannot be set to None"
" for this FidelityComputer.")
else:
raise errors.UsageError(
"No option for phase_option '{}'".format(value))
dyn.stats = sts
optim.stats = sts
# Configure the dynamics
dyn.drift_dyn_gen = drift
dyn.ctrl_dyn_gen = ctrls
dyn.initial = initial
dyn.target = target
if tau is None:
# Check that parameters have been supplied to generate the
# timeslot durations
try:
evo_time / num_tslots
except:
raise errors.UsageError(
"Either the timeslot durations should be supplied as an "
"array 'tau' or the number of timeslots 'num_tslots' "
"and the evolution time 'evo_time' must be given.")
dyn.num_tslots = num_tslots
dyn.evo_time = evo_time
else:
dyn.tau = tau
# this function is called, so that the num_ctrls attribute will be set
n_ctrls = dyn.num_ctrls
ramping_pgen = None
if ramping_pulse_type:
ramping_pgen = pulsegen.create_pulse_gen(
pulse_type=ramping_pulse_type, dyn=dyn,
def get_fid_err_gradient(self):
"""
Returns the normalised gradient of the fidelity error
in a (nTimeslots x n_ctrls) array wrt the timeslot control amplitude
"""
# must be implemented by subclass
raise errors.UsageError("No method defined for getting fidelity"
" error gradient. Suspect base class was"
def reset(self):
FidelityComputer.reset(self)
self.id_text = 'TRACEDIFF'
self.scale_factor = None
self.uses_onwd_evo = True
if not self.parent.prop_computer.grad_exact:
raise errors.UsageError(
"This FidelityComputer can only be"
" used with an exact gradient PropagatorComputer.")
self.apply_params()