Skip to content

Commit 109aad0

Browse files
authored
Merge pull request #365 from fooof-tools/mdef
[MNT] - Minor updates to Modes & add check function
2 parents 3ab0453 + 8039c90 commit 109aad0

File tree

4 files changed

+44
-3
lines changed

4 files changed

+44
-3
lines changed

specparam/modes/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Functionality related to definining fit modes."""

specparam/modes/definitions.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,33 @@
148148
'skewed_gaussian' : pe_skewnorm,
149149
'cauchy' : pe_cauchy,
150150
}
151+
152+
###################################################################################################
153+
## ALL MODES
154+
155+
# Collect a store of all available modes
156+
MODES = {
157+
'aperiodic' : AP_MODES,
158+
'periodic' : PE_MODES,
159+
}
160+
161+
162+
def check_modes(component, check_params=False):
163+
"""Check the set of modes that are available.
164+
165+
Parameters
166+
----------
167+
component : {'aperiodic', 'periodic'}
168+
Which component to check available modes for.
169+
check_params : bool, optional, default: False
170+
Whether to print out information on the parameters of each mode.
171+
"""
172+
173+
print('Available {:s} modes:'.format(component))
174+
for mode in MODES[component].values():
175+
if not check_params:
176+
print(' {:10s} {:s}'.format(mode.name, mode.description))
177+
else:
178+
print('\n{:s}'.format(mode.name))
179+
print(' {:s}'.format(mode.description))
180+
mode.check_params()

specparam/modes/mode.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ def n_params(self):
8888
def check_params(self):
8989
"""Check the description of the parameters for the current mode."""
9090

91-
print('Parameters for the {} component in {} mode:'.format(\
92-
self.component, self.name))
91+
print('Parameters for the {} mode:'.format(self.name))
9392
for pkey, desc in self.params.descriptions.items():
94-
print('\t{:15s} {:s}'.format(pkey, desc))
93+
print(' {:15s} {:s}'.format(pkey, desc))
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""Tests for specparam.modes.definitions."""
2+
3+
from specparam.modes.definitions import *
4+
5+
###################################################################################################
6+
###################################################################################################
7+
8+
def test_check_modes():
9+
10+
check_modes('aperiodic')
11+
check_modes('periodic')

0 commit comments

Comments
 (0)