Skip to content

Commit bc7df03

Browse files
committed
Run ruff.
1 parent 617f9f9 commit bc7df03

1 file changed

Lines changed: 14 additions & 26 deletions

File tree

test/test_cifti_cli_comprehensive.py

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ def _make_parcels_axis(parcel_names: list[str]) -> ParcelsAxis:
3434
nvertices = {'CIFTI_STRUCTURE_CORTEX_LEFT': n}
3535
vox_dtype = np.dtype([('ijk', '<i4', (3,))])
3636
voxels = [np.array([], dtype=vox_dtype) for _ in range(n)]
37-
vertices = [
38-
{'CIFTI_STRUCTURE_CORTEX_LEFT': np.array([i], dtype=np.int32)} for i in range(n)
39-
]
37+
vertices = [{'CIFTI_STRUCTURE_CORTEX_LEFT': np.array([i], dtype=np.int32)} for i in range(n)]
4038
return ParcelsAxis(parcel_names, voxels, vertices, np.eye(4), (10, 10, 10), nvertices)
4139

4240

@@ -205,10 +203,9 @@ def test_multiple_scalar_names(self, tmp_path):
205203
paths_thick = _write_dscalar_subjects(tmp_path, mask, scalar_name='THICK')
206204
paths_area = _write_dscalar_subjects(tmp_path, mask, scalar_name='AREA')
207205
cohort = tmp_path / 'cohort.csv'
208-
rows = (
209-
[{'scalar_name': 'THICK', 'source_file': str(p)} for p in paths_thick]
210-
+ [{'scalar_name': 'AREA', 'source_file': str(p)} for p in paths_area]
211-
)
206+
rows = [{'scalar_name': 'THICK', 'source_file': str(p)} for p in paths_thick] + [
207+
{'scalar_name': 'AREA', 'source_file': str(p)} for p in paths_area
208+
]
212209
_write_cohort_csv(cohort, rows)
213210
out_h5 = tmp_path / 'out.h5'
214211
cifti_to_h5(cohort, output=out_h5)
@@ -320,9 +317,7 @@ def test_pscalar_from_toy_data_axes(self, tmp_path):
320317
paths.append(p)
321318

322319
cohort = tmp_path / 'cohort.csv'
323-
_write_cohort_csv(
324-
cohort, [{'scalar_name': 'FC', 'source_file': str(p)} for p in paths]
325-
)
320+
_write_cohort_csv(cohort, [{'scalar_name': 'FC', 'source_file': str(p)} for p in paths])
326321
out_h5 = tmp_path / 'out.h5'
327322
assert cifti_to_h5(cohort, output=out_h5) == 0
328323
with h5py.File(out_h5, 'r') as h5:
@@ -536,7 +531,10 @@ def test_pvalue_1m_values_are_complement(self, tmp_path):
536531
out_dir.mkdir()
537532
h5_to_cifti(str(example), str(h5_path), 'analysis', str(out_dir))
538533
p_data = (
539-
nb.load(out_dir / 'analysis_p.value.dscalar.nii').get_fdata().squeeze().astype(np.float32)
534+
nb.load(out_dir / 'analysis_p.value.dscalar.nii')
535+
.get_fdata()
536+
.squeeze()
537+
.astype(np.float32)
540538
)
541539
oneminus = (
542540
nb.load(out_dir / 'analysis_1m.p.value.dscalar.nii')
@@ -650,9 +648,7 @@ def test_pscalar_from_toy_data_axes(self, tmp_path):
650648
n_parcels = len(parcel_axis)
651649

652650
header = nb.cifti2.Cifti2Header.from_axes((scalar_axis, parcel_axis))
653-
template = nb.Cifti2Image(
654-
np.zeros((1, n_parcels), dtype=np.float32), header=header
655-
)
651+
template = nb.Cifti2Image(np.zeros((1, n_parcels), dtype=np.float32), header=header)
656652
example_path = tmp_path / 'example_real.pscalar.nii'
657653
template.to_filename(example_path)
658654

@@ -690,9 +686,7 @@ def test_pconn_output_file_created(self, tmp_path):
690686
n = len(self.PARCELS)
691687
example = _make_pconn_example(tmp_path, self.PARCELS)
692688
h5_path = tmp_path / 'results.h5'
693-
_make_h5_results(
694-
h5_path, 'analysis', np.ones((1, n * n), np.float32), ['beta']
695-
)
689+
_make_h5_results(h5_path, 'analysis', np.ones((1, n * n), np.float32), ['beta'])
696690
out_dir = tmp_path / 'out'
697691
out_dir.mkdir()
698692
h5_to_cifti(str(example), str(h5_path), 'analysis', str(out_dir))
@@ -702,9 +696,7 @@ def test_pconn_not_dscalar_extension(self, tmp_path):
702696
n = len(self.PARCELS)
703697
example = _make_pconn_example(tmp_path, self.PARCELS)
704698
h5_path = tmp_path / 'results.h5'
705-
_make_h5_results(
706-
h5_path, 'analysis', np.ones((1, n * n), np.float32), ['beta']
707-
)
699+
_make_h5_results(h5_path, 'analysis', np.ones((1, n * n), np.float32), ['beta'])
708700
out_dir = tmp_path / 'out'
709701
out_dir.mkdir()
710702
h5_to_cifti(str(example), str(h5_path), 'analysis', str(out_dir))
@@ -716,9 +708,7 @@ def test_pconn_output_shape(self, tmp_path):
716708
n = len(self.PARCELS)
717709
example = _make_pconn_example(tmp_path, self.PARCELS)
718710
h5_path = tmp_path / 'results.h5'
719-
_make_h5_results(
720-
h5_path, 'analysis', np.ones((1, n * n), np.float32), ['beta']
721-
)
711+
_make_h5_results(h5_path, 'analysis', np.ones((1, n * n), np.float32), ['beta'])
722712
out_dir = tmp_path / 'out'
723713
out_dir.mkdir()
724714
h5_to_cifti(str(example), str(h5_path), 'analysis', str(out_dir))
@@ -845,9 +835,7 @@ def test_main_pscalar_with_example_cifti(self, tmp_path):
845835
parcels = ['A', 'B', 'C']
846836
example = _make_pscalar_example(tmp_path, parcels)
847837
h5_path = tmp_path / 'results.h5'
848-
_make_h5_results(
849-
h5_path, 'analysis', np.ones((1, len(parcels)), np.float32), ['beta']
850-
)
838+
_make_h5_results(h5_path, 'analysis', np.ones((1, len(parcels)), np.float32), ['beta'])
851839
out_dir = tmp_path / 'out'
852840
result = h5_to_cifti_main(
853841
analysis_name='analysis',

0 commit comments

Comments
 (0)