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 Jan 9, 2025
1 parent f3bc682 commit 6cf2fec
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions tests/test_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from pathlib import Path
from types import SimpleNamespace
from unittest.mock import patch
import matplotlib.pyplot as plt

import matplotlib.pyplot as plt
import pypulseq as pp
import pytest
from _pytest.python_api import ApproxBase
Expand Down Expand Up @@ -316,15 +316,15 @@ def test_writeread(self, seq_func, tmp_path, compare_seq_file):
assert False

# 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 @@ -363,9 +363,9 @@ def test_recreate(self, seq_func, tmp_path):
# 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']):
Expand All @@ -374,15 +374,15 @@ def test_recreate(self, seq_func, tmp_path):
if a == None or b == None:
assert False

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 6cf2fec

Please sign in to comment.