Skip to content

Commit

Permalink
[pre-commit] auto fixes from pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Feb 3, 2025
1 parent adacb75 commit beaa318
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/pypulseq/make_adc.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def make_adc(

if adc.dead_time > adc.delay:
warn(
f'Specified ADC delay {adc.delay*1e6:.2f} us is less than the dead time {adc.dead_time*1e6:.0f} us. Delay was increased to the dead time.',
f'Specified ADC delay {adc.delay * 1e6:.2f} us is less than the dead time {adc.dead_time * 1e6:.0f} us. Delay was increased to the dead time.',
stacklevel=2,
)
adc.delay = adc.dead_time
Expand Down
2 changes: 1 addition & 1 deletion src/pypulseq/make_adiabatic_pulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def make_adiabatic_pulse(
rf.use = use if use != '' else 'inversion'
if rf.dead_time > rf.delay:
warn(
f'Specified RF delay {rf.delay*1e6:.2f} us is less than the dead time {rf.dead_time*1e6:.0f} us. Delay was increased to the dead time.',
f'Specified RF delay {rf.delay * 1e6:.2f} us is less than the dead time {rf.dead_time * 1e6:.0f} us. Delay was increased to the dead time.',
stacklevel=2,
)
rf.delay = rf.dead_time
Expand Down
2 changes: 1 addition & 1 deletion src/pypulseq/make_arbitrary_rf.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def make_arbitrary_rf(

if rf.dead_time > rf.delay:
warn(
f'Specified RF delay {rf.delay*1e6:.2f} us is less than the dead time {rf.dead_time*1e6:.0f} us. Delay was increased to the dead time.',
f'Specified RF delay {rf.delay * 1e6:.2f} us is less than the dead time {rf.dead_time * 1e6:.0f} us. Delay was increased to the dead time.',
stacklevel=2,
)
rf.delay = rf.dead_time
Expand Down
4 changes: 2 additions & 2 deletions src/pypulseq/make_block_pulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def make_block_pulse(

valid_use_pulses = get_supported_rf_uses()
if use != '' and use not in valid_use_pulses:
raise ValueError('Invalid use parameter. ' f'Must be one of {valid_use_pulses}. Passed: {use}')
raise ValueError(f'Invalid use parameter. Must be one of {valid_use_pulses}. Passed: {use}')

if duration is None and bandwidth is None:
warn('Using default 4 ms duration for block pulse.')
Expand Down Expand Up @@ -110,7 +110,7 @@ def make_block_pulse(

if rf.dead_time > rf.delay:
warn(
f'Specified RF delay {rf.delay*1e6:.2f} us is less than the dead time {rf.dead_time*1e6:.0f} us. Delay was increased to the dead time.',
f'Specified RF delay {rf.delay * 1e6:.2f} us is less than the dead time {rf.dead_time * 1e6:.0f} us. Delay was increased to the dead time.',
stacklevel=2,
)
rf.delay = rf.dead_time
Expand Down
2 changes: 1 addition & 1 deletion src/pypulseq/make_gauss_pulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def make_gauss_pulse(

if rf.dead_time > rf.delay:
warn(
f'Specified RF delay {rf.delay*1e6:.2f} us is less than the dead time {rf.dead_time*1e6:.0f} us. Delay was increased to the dead time.',
f'Specified RF delay {rf.delay * 1e6:.2f} us is less than the dead time {rf.dead_time * 1e6:.0f} us. Delay was increased to the dead time.',
stacklevel=2,
)
rf.delay = rf.dead_time
Expand Down
2 changes: 1 addition & 1 deletion src/pypulseq/make_sigpy_pulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def sigpy_n_seq(

if rfp.dead_time > rfp.delay:
warn(
f'Specified RF delay {rfp.delay*1e6:.2f} us is less than the dead time {rfp.dead_time*1e6:.0f} us. Delay was increased to the dead time.',
f'Specified RF delay {rfp.delay * 1e6:.2f} us is less than the dead time {rfp.dead_time * 1e6:.0f} us. Delay was increased to the dead time.',
stacklevel=2,
)
rfp.delay = rfp.dead_time
Expand Down
2 changes: 1 addition & 1 deletion src/pypulseq/make_sinc_pulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def make_sinc_pulse(

if rf.dead_time > rf.delay:
warn(
f'Specified RF delay {rf.delay*1e6:.2f} us is less than the dead time {rf.dead_time*1e6:.0f} us. Delay was increased to the dead time.',
f'Specified RF delay {rf.delay * 1e6:.2f} us is less than the dead time {rf.dead_time * 1e6:.0f} us. Delay was increased to the dead time.',
stacklevel=2,
)
rf.delay = rf.dead_time
Expand Down
4 changes: 2 additions & 2 deletions src/pypulseq/make_trapezoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,12 @@ def make_trapezoid(

if abs(amplitude2) / rise_time > max_slew:
raise ValueError(
f'Refined slew rate ({abs(amplitude2)/rise_time:0.0f} Hz/m/s) for ramp up is larger than max ({max_slew:0.0f} Hz/m/s).'
f'Refined slew rate ({abs(amplitude2) / rise_time:0.0f} Hz/m/s) for ramp up is larger than max ({max_slew:0.0f} Hz/m/s).'
)

if abs(amplitude2) / fall_time > max_slew:
raise ValueError(
f'Refined slew rate ({abs(amplitude2)/fall_time:0.0f} Hz/m/s) for ramp down is larger than max ({max_slew:0.0f} Hz/m/s).'
f'Refined slew rate ({abs(amplitude2) / fall_time:0.0f} Hz/m/s) for ramp down is larger than max ({max_slew:0.0f} Hz/m/s).'
)

grad = SimpleNamespace()
Expand Down
2 changes: 1 addition & 1 deletion src/pypulseq/opts.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __init__(

if grad_unit not in valid_grad_units:
raise ValueError(
f"Invalid gradient unit. Must be one of 'Hz/m', 'mT/m' or 'rad/ms/mm'. " f'Passed: {grad_unit}'
f"Invalid gradient unit. Must be one of 'Hz/m', 'mT/m' or 'rad/ms/mm'. Passed: {grad_unit}"
)

if slew_unit not in valid_slew_units:
Expand Down
6 changes: 3 additions & 3 deletions src/pypulseq/utils/safe_pns_prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,9 @@ def safe_plot(pns, dt=None, envelope=True, envelope_points=500):

plt.legend(
[
f'X ({max(pns[:,0]):0.0f}%)',
f'Y ({max(pns[:,1]):0.0f}%)',
f'Z ({max(pns[:,2]):0.0f}%)',
f'X ({max(pns[:, 0]):0.0f}%)',
f'Y ({max(pns[:, 1]):0.0f}%)',
f'Z ({max(pns[:, 2]):0.0f}%)',
f'nrm ({max(pnsnorm):0.0f}%)',
],
loc='best',
Expand Down
42 changes: 21 additions & 21 deletions tests/test_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,15 @@ def test_writeread(self, seq_func, tmp_path, compare_seq_file):
assert a is not None and b is not None

# TODO: C[0] is slope of gradient, on the order of max_slew? So expect abs rounding errors in range of 1e2?
assert a.x == Approx(
b.x, abs=1e-5, rel=1e-5
), f'Time axis of gradient waveform for channel {channel} does not match'
assert a.c[0] == Approx(
b.c[0], abs=1e2, rel=1e-3
), f'First-order coefficients of piecewise-polynomial gradient waveform for channel {channel} do not match'
assert a.c[1] == Approx(
b.c[1], abs=1e-5, rel=1e-5
), f'Zero-order coefficients of piecewise-polynomial gradient waveform for channel {channel} do not match'
assert a.x == Approx(b.x, abs=1e-5, rel=1e-5), (
f'Time axis of gradient waveform for channel {channel} does not match'
)
assert a.c[0] == Approx(b.c[0], abs=1e2, rel=1e-3), (
f'First-order coefficients of piecewise-polynomial gradient waveform for channel {channel} do not match'
)
assert a.c[1] == Approx(b.c[1], abs=1e-5, rel=1e-5), (
f'Zero-order coefficients of piecewise-polynomial gradient waveform for channel {channel} do not match'
)

# Restore RF use for k-space calculation
for block_counter in seq.block_events:
Expand Down Expand Up @@ -372,25 +372,25 @@ def test_recreate(self, seq_func): # noqa: ARG002
# Test for approximate equality of all blocks
assert list(seq2.block_events.keys()) == list(seq.block_events.keys()), 'Sequence block IDs are not identical'
for block_counter in seq.block_events:
assert seq2.get_block(block_counter) == Approx(
seq.get_block(block_counter), abs=1e-9, rel=1e-9
), f'Block {block_counter} does not match'
assert seq2.get_block(block_counter) == Approx(seq.get_block(block_counter), abs=1e-9, rel=1e-9), (
f'Block {block_counter} does not match'
)

# Test for approximate equality of all gradient waveforms
for a, b, channel in zip(seq2.get_gradients(), seq.get_gradients(), ['x', 'y', 'z']):
if a is None and b is None:
continue
assert a is not None and b is not None

assert a.x == Approx(
b.x, abs=1e-9, rel=1e-9
), f'Time axis of gradient waveform for channel {channel} does not match'
assert a.c[0] == Approx(
b.c[0], abs=1e-9, rel=1e-9
), f'First-order coefficients of piecewise-polynomial gradient waveform for channel {channel} do not match'
assert a.c[1] == Approx(
b.c[1], abs=1e-9, rel=1e-9
), f'Zero-order coefficients of piecewise-polynomial gradient waveform for channel {channel} do not match'
assert a.x == Approx(b.x, abs=1e-9, rel=1e-9), (
f'Time axis of gradient waveform for channel {channel} does not match'
)
assert a.c[0] == Approx(b.c[0], abs=1e-9, rel=1e-9), (
f'First-order coefficients of piecewise-polynomial gradient waveform for channel {channel} do not match'
)
assert a.c[1] == Approx(b.c[1], abs=1e-9, rel=1e-9), (
f'Zero-order coefficients of piecewise-polynomial gradient waveform for channel {channel} do not match'
)

# Test for approximate equality of kspace calculation
assert seq2.calculate_kspace() == Approx(seq.calculate_kspace(), abs=1e-6, nan_ok=True)
Expand Down

0 comments on commit beaa318

Please sign in to comment.