Skip to content

Commit b8927fe

Browse files
committed
lints
1 parent dd621d7 commit b8927fe

File tree

5 files changed

+17
-26
lines changed

5 files changed

+17
-26
lines changed

specparam/objs/algorithm.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ class SpectralFitAlgorithm():
4545
_maxfev : int
4646
The maximum number of calls to the curve fitting function.
4747
_error_metric : str
48-
The error metric to use for post-hoc measures of model fit error. See `_calc_error` for options.
48+
The error metric to use for post-hoc measures of model fit error.
4949
Note: this is for checking error post fitting, not an objective function for fitting.
50+
See `_calc_error` for options.
5051
_debug : bool
5152
Run mode: whether the object is set in debug mode.
5253
If in debug mode, an error is raised if model fitting is unsuccessful.
@@ -55,7 +56,7 @@ class SpectralFitAlgorithm():
5556
Attributes
5657
----------
5758
_gauss_std_limits : list of [float, float]
58-
Settings attribute: peak width limits, converted to use for gaussian standard deviation parameter.
59+
Settings attribute: peak width limits, to use for gaussian standard deviation parameter.
5960
This attribute is computed based on `peak_width_limits` and should not be updated directly.
6061
_spectrum_flat : 1d array
6162
Data attribute: flattened power spectrum, with the aperiodic component removed.
@@ -194,7 +195,8 @@ def _reset_internal_settings(self):
194195
self._gauss_std_limits = None
195196

196197

197-
# ToCheck: this currently overrides basefit - but once modes are used, this can be dropped (I think)
198+
# ToCheck: this currently overrides basefit
199+
# Once modes are used, this can be dropped (I think)
198200
def _reset_results(self, clear_results=False):
199201
"""Set, or reset, results attributes to empty.
200202

specparam/objs/base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from specparam.core.io import (save_model, save_group, save_event,
1212
load_json, load_jsonlines, get_files)
1313
from specparam.core.modutils import copy_doc_func_to_method
14-
from specparam.plts.event import plot_event_model
1514
from specparam.objs.results import BaseResults, BaseResults2D, BaseResults2DT, BaseResults3D
1615
from specparam.objs.data import BaseData, BaseData2D, BaseData2DT, BaseData3D
1716

@@ -443,5 +442,5 @@ def _reset_data_results(self, clear_freqs=False, clear_spectrum=False, clear_res
443442
Whether to clear spectrograms attribute.
444443
"""
445444

446-
self._reset_data(clear_freqs, clear_spectrum, clear_spectra)
445+
self._reset_data(clear_freqs, clear_spectrum, clear_spectra, clear_spectrograms)
447446
self._reset_results(clear_results)

specparam/objs/event.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
11
"""Event model object and associated code for fitting the model to spectrograms across events."""
22

3-
from itertools import repeat
4-
from functools import partial
5-
from multiprocessing import Pool, cpu_count
6-
73
import numpy as np
84

95
from specparam.objs import SpectralModel
106
from specparam.objs.base import BaseObject3D
117
from specparam.objs.algorithm import SpectralFitAlgorithm
12-
from specparam.objs.results import _progress
138
from specparam.plts.event import plot_event_model
14-
from specparam.data.conversions import event_group_to_dict, event_group_to_dataframe, dict_to_df
15-
from specparam.data.utils import get_group_params, get_results_by_row, flatten_results_dict
9+
from specparam.data.conversions import event_group_to_dataframe, dict_to_df
10+
from specparam.data.utils import flatten_results_dict
1611
from specparam.core.modutils import (copy_doc_func_to_method, docs_get_section,
1712
replace_docstring_sections)
1813
from specparam.core.reports import save_event_report
1914
from specparam.core.strings import gen_event_results_str
20-
from specparam.core.utils import check_inds
21-
from specparam.core.io import get_files, save_event
2215

2316
###################################################################################################
2417
###################################################################################################
@@ -105,7 +98,7 @@ def report(self, freqs=None, spectrograms=None, freq_range=None,
10598
Data is optional, if data has already been added to the object.
10699
"""
107100

108-
self.fit(freqs, spectrograms, freq_range, peak_org, n_jobs=n_jobs, progress=progress)
101+
self.fit(freqs, spectrograms, freq_range, peak_org, n_jobs, progress)
109102
self.plot()
110103
self.print_results()
111104

specparam/objs/results.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ def get_model(self, ind, regenerate=True):
554554
The FitResults data loaded into a model object.
555555
"""
556556

557-
# TEMP IMPORT
557+
# Local import - avoid circular
558558
from specparam.objs.model import SpectralModel
559559

560560
# Initialize model object, with same settings, metadata, & check mode as current object
@@ -588,7 +588,7 @@ def get_group(self, inds):
588588
The requested selection of results data loaded into a new group model object.
589589
"""
590590

591-
# TEMP IMPORT
591+
# Local import - avoid circular
592592
from specparam.objs.group import SpectralGroupModel
593593

594594
# Initialize a new model object, with same settings as current object
@@ -690,12 +690,9 @@ def get_group(self, inds, output_type='time'):
690690
The requested selection of results data loaded into a new model object.
691691
"""
692692

693-
# TEMP IMPORT
694-
from specparam.objs.time import SpectralTimeModel
695-
696693
if output_type == 'time':
697694

698-
# TEMP IMPORT
695+
# Local import - avoid circular
699696
from specparam.objs.time import SpectralTimeModel
700697

701698
# Initialize a new model object, with same settings as current object
@@ -874,7 +871,7 @@ def drop(self, drop_inds=None, window_inds=None):
874871
This method sets the model fits as null, and preserves the shape of the model fits.
875872
"""
876873

877-
# TEMP IMPORT
874+
# Local import - avoid circular
878875
from specparam.objs.model import SpectralModel
879876

880877
null_model = SpectralModel(**self.get_settings()._asdict()).get_results()
@@ -966,7 +963,7 @@ def get_group(self, event_inds, window_inds, output_type='event'):
966963
The requested selection of results data loaded into a new model object.
967964
"""
968965

969-
# TEMP IMPORT
966+
# Local import - avoid circular
970967
from specparam.objs.event import SpectralTimeEventModel
971968

972969
# Check and convert indices encoding to list of int

specparam/utils/data.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ def compute_presence(data, average=False, output='ratio'):
9292
data : 1d or 2d array
9393
Data array to check presence of.
9494
average : bool, optional, default: False
95-
Whether to average across . Only used for 2d array inputs.
96-
If False, for 2d array, the output is an array matching the length of the 0th dimension of the input.
97-
If True, for 2d arrays, the output is a single value averaged across the whole array.
95+
Whether to average across. Only used for 2d array inputs.
96+
If False, the output is an array matching the length of the 0th dimension of the input.
97+
If True, the output is a single value averaged across the whole array.
9898
output : {'ratio', 'percent'}
9999
Representation for the output:
100100
'ratio' - ratio value, between 0.0, 1.0.

0 commit comments

Comments
 (0)