1- """"Utility functions for working with data and data objects.
2- TODO
3- """
1+ """"Utility functions for working with data and data objects."""
42
53import numpy as np
64
@@ -65,11 +63,11 @@ def get_model_params(fit_results, modes, component, field=None, version=None):
6563 Results of a model fit.
6664 modes : Modes
6765 Model modes definition.
68- component : {'aperiodic', 'peak', 'metrics' }
66+ component : {'aperiodic', 'peak'}
6967 Name of the component to extract.
7068 field : str or int, optional
7169 Column name / index to extract from selected data, if requested.
72- For example, {'CF', 'PW', 'BW'} (periodic) or {'offset', 'knee', 'exponent'} (aperiodic) .
70+ See `SpectralModel.modes.check_params` for a description of parameter field names .
7371
7472 Returns
7573 -------
@@ -84,9 +82,8 @@ def get_model_params(fit_results, modes, component, field=None, version=None):
8482
8583 # Use helper function to sort out name and column selection
8684 ind = None
87- if component in ['aperiodic' , 'peak' ]:
88- ind = _get_field_ind (modes , component , field )
89- component = component + '_' + version
85+ ind = _get_field_ind (modes , component , field )
86+ component = component + '_' + version
9087
9188 # Extract the requested data attribute from object
9289 out = getattr (fit_results , component )
@@ -98,14 +95,9 @@ def get_model_params(fit_results, modes, component, field=None, version=None):
9895 # Select out a specific column, if requested
9996 if ind is not None :
10097
101- if component == 'metrics' :
102- out = out [ind ]
103-
104- else :
105-
106- # Extract column, & if result is a single value in an array, unpack from array
107- out = out [ind ] if out .ndim == 1 else out [:, ind ]
108- out = out [0 ] if isinstance (out , np .ndarray ) and out .size == 1 else out
98+ # Extract column, & if result is a single value in an array, unpack from array
99+ out = out [ind ] if out .ndim == 1 else out [:, ind ]
100+ out = out [0 ] if isinstance (out , np .ndarray ) and out .size == 1 else out
109101
110102 return out
111103
@@ -119,11 +111,11 @@ def get_group_params(group_results, modes, component, field=None, version=None):
119111 List of FitResults objects, reflecting model results across a group of power spectra.
120112 modes : Modes
121113 Model modes definition.
122- component : {'aperiodic', 'peak', 'metrics' }
114+ component : {'aperiodic', 'peak'}
123115 Name of the data field to extract across the group.
124116 field : str or int, optional
125117 Column name / index to extract from selected data, if requested.
126- For example, {'CF', 'PW', 'BW'} (periodic) or {'offset', 'knee', 'exponent'} (aperiodic) .
118+ See `SpectralModel.modes.check_params` for a description of parameter field names .
127119 version : {'fit', 'converted'}, optional
128120 TODO
129121
@@ -140,9 +132,8 @@ def get_group_params(group_results, modes, component, field=None, version=None):
140132
141133 # Use helper function to sort out name and column selection
142134 ind = None
143- if component in ['aperiodic' , 'peak' ]:
144- ind = _get_field_ind (modes , component , field )
145- component = component + '_' + version
135+ ind = _get_field_ind (modes , component , field )
136+ component = component + '_' + version
146137
147138 # Pull out the requested data field from the group data
148139 # As a special case, peak_params are pulled out in a way that appends
@@ -163,11 +154,7 @@ def get_group_params(group_results, modes, component, field=None, version=None):
163154
164155 # Select out a specific column, if requested
165156 if ind is not None :
166-
167- if component == 'metrics' :
168- out = np .array ([cdict [ind ] for cdict in out ])
169- else :
170- out = out [:, ind ]
157+ out = out [:, ind ]
171158
172159 return out
173160
0 commit comments