Skip to content

Commit 3f3b34a

Browse files
committed
feat: add setters and getters for run_modes and update documentation
1 parent fe946da commit 3f3b34a

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

fooof/objs/fit.py

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
_debug : bool
4646
Whether the object is set in debug mode.
4747
This should be controlled by using the `set_debug_mode` method.
48+
_check_freqs: bool
49+
Whether to checked added added frequency values for even linear spacing.
4850
_check_data : bool
4951
Whether to check added data for NaN or Inf values, and fail out if present.
5052
This should be controlled by using the `set_check_data_mode` method.
@@ -199,7 +201,7 @@ def __init__(self, peak_width_limits=(0.5, 12.0), max_n_peaks=np.inf, min_peak_h
199201
# Set default debug mode - controls if an error is raised if model fitting is unsuccessful
200202
self._debug = False
201203
# Set default data checking modes - controls which checks get run on input data
202-
# check_freqs: check the frequency values, and raises an error for uneven spacing
204+
# check_freqs: checks the frequency values, and raises an error for uneven spacing
203205
self._check_freqs = True
204206
# check_data: checks the power values and raises an error for any NaN / Inf values
205207
self._check_data = True
@@ -568,6 +570,19 @@ def get_settings(self):
568570
for key in OBJ_DESC['settings']})
569571

570572

573+
def get_run_modes(self):
574+
"""Return run modes of the current object.
575+
576+
Returns
577+
-------
578+
FOOOFRunModes
579+
Object containing the run_modes from the current object.
580+
"""
581+
582+
return FOOOFRunModes(**{key : getattr(self, key) \
583+
for key in OBJ_DESC['run_modes']})
584+
585+
571586
def get_meta_data(self):
572587
"""Return data information from the current object.
573588
@@ -723,6 +738,18 @@ def set_debug_mode(self, debug):
723738
self._debug = debug
724739

725740

741+
def set_check_freqs_mode(self, check_freqs):
742+
"""Set check freqs mode, which controls if an error is raised for unevenly spaced input frequencies.
743+
744+
Parameters
745+
----------
746+
check_freqs : bool
747+
Whether to run in check freqs mode.
748+
"""
749+
750+
self._check_freqs = check_freqs
751+
752+
726753
def set_check_data_mode(self, check_data):
727754
"""Set check data mode, which controls if an error is raised if NaN or Inf data are added.
728755
@@ -735,6 +762,23 @@ def set_check_data_mode(self, check_data):
735762
self._check_data = check_data
736763

737764

765+
def set_run_modes(self, debug, check_freqs, check_data):
766+
"""Simultaneously set all run modes.
767+
768+
Parameters
769+
----------
770+
debug : bool
771+
Whether to run in debug mode.
772+
check_freqs : bool
773+
Whether to run in check freqs mode.
774+
check_data : bool
775+
Whether to run in check data mode.
776+
"""
777+
self._debug = debug
778+
self._check_freqs = check_freqs
779+
self._check_data = check_data
780+
781+
738782
def to_df(self, peak_org):
739783
"""Convert and extract the model results as a pandas object.
740784

0 commit comments

Comments
 (0)