Skip to content

Commit

Permalink
Fix small errors
Browse files Browse the repository at this point in the history
  • Loading branch information
thangleiter committed May 26, 2020
1 parent ba3b685 commit e06d742
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions filter_functions/pulse_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ def cleanup(self, method: str = 'conservative') -> None:
resulting in slower execution of the concatenation.
"""
default_attrs = {'_HD', '_HV', '_Q'}
concatenation_attrs = {'_total_Q', '_total_Q_liouville', '_R', '_R_kl',
concatenation_attrs = {'_total_Q', '_total_Q_liouville', '_R', '_R_pc',
'_total_phases'}
filter_function_attrs = {'omega', '_F', '_F_kl', '_F_pc', '_F_pc_kl'}

Expand All @@ -887,7 +887,7 @@ def cleanup(self, method: str = 'conservative') -> None:
elif method == 'greedy':
attrs = default_attrs.union(concatenation_attrs)
elif method == 'frequency dependent':
attrs = filter_function_attrs.union({'_R', '_R_kl',
attrs = filter_function_attrs.union({'_R', '_R_pc',
'_total_phases'})
else:
attrs = filter_function_attrs.union(default_attrs,
Expand Down
7 changes: 4 additions & 3 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,10 @@ def test_pulse_sequence_attributes(self):
setattr(A, attr, 'foo')
assertion = self.assertTrue
else:
setattr(A, attr, None)
assertion = self.assertFalse

assertion(A.is_cached(attr))
setattr(A, attr, None)

aliases = {'eigenvalues': '_HD',
'eigenvectors': '_HV',
Expand All @@ -348,21 +348,22 @@ def test_pulse_sequence_attributes(self):
'fidelity pulse correlation filter function': '_F_pc',
'generalized pulse correlation filter function': '_F_pc_kl',
'control matrix': '_R',
'pulse correlation control matrix': '_R'}
'pulse correlation control matrix': '_R_pc'}

for alias, attr in aliases.items():
# set mock attribute at random
if testutil.rng.randint(0, 2):
setattr(A, attr, 'foo')
assertion = self.assertTrue
else:
setattr(A, attr, None)
assertion = self.assertFalse

assertion(A.is_cached(alias))
assertion(A.is_cached(alias.upper()))
assertion(A.is_cached(alias.replace(' ', '_')))

setattr(A, attr, None)
A.cleanup('all')

# Test cleanup
C = ff.concatenate((A, A), calc_pulse_correlation_ff=True,
Expand Down

0 comments on commit e06d742

Please sign in to comment.