Skip to content

Commit d7e4483

Browse files
committed
Run ruff with unsafe-fixes.
1 parent dbfe3a6 commit d7e4483

6 files changed

Lines changed: 27 additions & 37 deletions

File tree

src/modelarrayio/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
EXTRA_REQUIRES['docs'] = EXTRA_REQUIRES['doc']
7171

7272
# Enable a handle to install all extra dependencies at once
73-
EXTRA_REQUIRES['all'] = list(set([v for deps in EXTRA_REQUIRES.values() for v in deps]))
73+
EXTRA_REQUIRES['all'] = list({v for deps in EXTRA_REQUIRES.values() for v in deps})
7474

7575
CLASSIFIERS = [
7676
'Development Status :: 3 - Alpha',

src/modelarrayio/cifti.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def write_storage(
301301
return 0
302302

303303
# Establish a reference brain axis once to ensure consistent ordering across workers.
304-
first_scalar, first_sources = next(iter(scalar_sources.items()))
304+
_first_scalar, first_sources = next(iter(scalar_sources.items()))
305305
first_path = op.join(relative_root, first_sources[0])
306306
_, reference_brain_names = extract_cifti_scalar_data(first_path)
307307

src/modelarrayio/fixels.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def gather_fixels(index_file, directions_file):
8989
path to a Nifti2 directions file
9090
"""
9191

92-
index_img, index_data = mif_to_nifti2(index_file)
92+
_index_img, index_data = mif_to_nifti2(index_file)
9393
count_vol = index_data[..., 0].astype(
9494
np.uint32
9595
) # number of fixels in each voxel; by index.mif definition
@@ -123,23 +123,23 @@ def gather_fixels(index_file, directions_file):
123123
sorted_coords = voxel_coords[id_sort]
124124

125125
voxel_table = pd.DataFrame(
126-
dict(
127-
voxel_id=np.arange(voxel_coords.shape[0]),
128-
i=sorted_coords[:, 0],
129-
j=sorted_coords[:, 1],
130-
k=sorted_coords[:, 2],
131-
)
126+
{
127+
'voxel_id': np.arange(voxel_coords.shape[0]),
128+
'i': sorted_coords[:, 0],
129+
'j': sorted_coords[:, 1],
130+
'k': sorted_coords[:, 2],
131+
}
132132
)
133133

134-
directions_img, directions_data = mif_to_nifti2(directions_file)
134+
_directions_img, directions_data = mif_to_nifti2(directions_file)
135135
fixel_table = pd.DataFrame(
136-
dict(
137-
fixel_id=fixel_ids,
138-
voxel_id=fixel_voxel_ids,
139-
x=directions_data[:, 0],
140-
y=directions_data[:, 1],
141-
z=directions_data[:, 2],
142-
)
136+
{
137+
'fixel_id': fixel_ids,
138+
'voxel_id': fixel_voxel_ids,
139+
'x': directions_data[:, 0],
140+
'y': directions_data[:, 1],
141+
'z': directions_data[:, 2],
142+
}
143143
)
144144

145145
return fixel_table, voxel_table
@@ -192,11 +192,11 @@ def write_storage(
192192
scalars = defaultdict(list)
193193
sources_lists = defaultdict(list)
194194
print('Extracting .mif data...')
195-
for ix, row in tqdm(
195+
for _ix, row in tqdm(
196196
cohort_df.iterrows(), total=cohort_df.shape[0]
197197
): # ix: index of row (start from 0); row: one row of data
198198
scalar_file = op.join(relative_root, row['source_file'])
199-
scalar_img, scalar_data = mif_to_nifti2(scalar_file)
199+
_scalar_img, scalar_data = mif_to_nifti2(scalar_file)
200200
scalars[row['scalar_name']].append(scalar_data) # append to specific scalar_name
201201
sources_lists[row['scalar_name']].append(
202202
row['source_file']

src/modelarrayio/voxels.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,12 @@ def write_storage(
294294

295295
# voxel_table: records the coordinations of the nonzero voxels; coord starts from 0 (because using python)
296296
voxel_table = pd.DataFrame(
297-
dict(
298-
voxel_id=np.arange(voxel_coords.shape[0]),
299-
i=voxel_coords[:, 0],
300-
j=voxel_coords[:, 1],
301-
k=voxel_coords[:, 2],
302-
)
297+
{
298+
'voxel_id': np.arange(voxel_coords.shape[0]),
299+
'i': voxel_coords[:, 0],
300+
'j': voxel_coords[:, 1],
301+
'k': voxel_coords[:, 2],
302+
}
303303
)
304304

305305
# upload each cohort's data

test/test_cifti_cli.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,7 @@ def test_concifti_cli_creates_expected_hdf5(tmp_path):
103103
# Column names exist and match subjects count
104104
grp = h5['scalars/THICK']
105105
assert 'column_names' in grp
106-
colnames = list(
107-
map(
108-
lambda x: x.decode('utf-8') if isinstance(x, bytes) else str(x),
109-
grp['column_names'][...],
110-
)
111-
)
106+
colnames = [x.decode('utf-8') if isinstance(x, bytes) else str(x) for x in grp['column_names'][...]]
112107
assert len(colnames) == 2
113108

114109
# Spot-check a couple values

test/test_voxels_cli.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,7 @@ def test_convoxel_cli_creates_expected_hdf5(tmp_path):
122122
# Column names exist and match subjects count
123123
grp = h5['scalars/FA']
124124
assert 'column_names' in grp
125-
colnames = list(
126-
map(
127-
lambda x: x.decode('utf-8') if isinstance(x, bytes) else str(x),
128-
grp['column_names'][...],
129-
)
130-
)
125+
colnames = [x.decode('utf-8') if isinstance(x, bytes) else str(x) for x in grp['column_names'][...]]
131126
assert len(colnames) == 2
132127

133128
# Spot-check a voxel mapping (pick the third voxel)

0 commit comments

Comments
 (0)