Skip to content

Commit cf721a2

Browse files
committed
small doc & code notes tweaks
1 parent 1f436cb commit cf721a2

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

fooof/core/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ def group_three(vec):
1313
1414
Parameters
1515
----------
16-
vec : 1d array
17-
Array of items to group by 3. Length of array must be divisible by three.
16+
vec : list or 1d array
17+
List or array of items to group by 3. Length of array must be divisible by three.
1818
1919
Returns
2020
-------
21-
list of list
22-
List of lists, each with three items.
21+
array or list of list
22+
Array or list of lists, each with three items. Output type will match input type.
2323
2424
Raises
2525
------
@@ -30,8 +30,8 @@ def group_three(vec):
3030
if len(vec) % 3 != 0:
3131
raise ValueError("Wrong size array to group by three.")
3232

33+
# Reshape, if an array, as it's faster, otherwise asssume lise
3334
if isinstance(vec, np.ndarray):
34-
# Reshaping is faster if already an array
3535
return np.reshape(vec, (-1, 3))
3636
else:
3737
return [list(vec[ii:ii+3]) for ii in range(0, len(vec), 3)]

fooof/objs/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,14 @@ def fit_fooof_3d(fg, freqs, power_spectra, freq_range=None, n_jobs=1):
219219
>>> fgs = fit_fooof_3d(fg, freqs, power_spectra, freq_range=[3, 30]) # doctest:+SKIP
220220
"""
221221

222-
# Reshape 3d to 2d and fit
222+
# Reshape 3d data to 2d and fit, in order to fit with a single group model object
223223
shape = np.shape(power_spectra)
224224
powers_2d = np.reshape(power_spectra, (shape[0] * shape[1], shape[2]))
225225

226226
fg.fit(freqs, powers_2d, freq_range, n_jobs)
227227

228-
# Reorganize 2d results
228+
# Reorganize 2d results into a list of model group objects, to reflect original shape
229229
fgs = [fg.get_group(range(dim_a * shape[1], (dim_a + 1) * shape[1])) \
230-
for dim_a in range(shape[0]) ]
230+
for dim_a in range(shape[0])]
231231

232232
return fgs

0 commit comments

Comments
 (0)