Skip to content

Commit

Permalink
finish lint: use docs updates & other small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TomDonoghue committed Mar 26, 2024
1 parent 5f1d94a commit 4f53829
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
5 changes: 1 addition & 4 deletions specparam/objs/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,6 @@ def fit(self, freqs=None, spectrograms=None, freq_range=None, peak_org=None,
Data is optional, if data has already been added to the object.
"""

# ToDo: here because of circular import - updates / refactors should fix & move
#from specparam.objs.group import _progress

if spectrograms is not None:
self.add_data(freqs, spectrograms, freq_range)

Expand Down Expand Up @@ -274,7 +271,7 @@ def drop(self, drop_inds=None, window_inds=None):
null_model = SpectralModel(*self.get_settings()).get_results()

drop_inds = drop_inds if isinstance(drop_inds, dict) else \
{eind : winds for eind, winds in zip(check_inds(drop_inds), repeat(window_inds))}
dict(zip(check_inds(drop_inds), repeat(window_inds)))

for eind, winds in drop_inds.items():

Expand Down
10 changes: 7 additions & 3 deletions specparam/sim/sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import numpy as np

from specparam.core.utils import check_iter, check_flat
from specparam.core.modutils import docs_get_section, replace_docstring_sections
from specparam.core.modutils import (docs_get_section, replace_docstring_sections,
docs_replace_param)
from specparam.sim.params import collect_sim_params
from specparam.sim.gen import gen_freqs, gen_power_vals, gen_rotated_power_vals
from specparam.sim.transform import compute_rotation_offset
Expand Down Expand Up @@ -259,8 +260,11 @@ def sim_group_power_spectra(n_spectra, freq_range, aperiodic_params, periodic_pa
else:
return freqs, powers

# ToDo: need an update to docstring to replace `n_spectra` with `n_windows`
@replace_docstring_sections(docs_get_section(sim_group_power_spectra.__doc__, 'Parameters'))

@replace_docstring_sections(\
docs_replace_param(docs_get_section(\
sim_group_power_spectra.__doc__, 'Parameters'),
'n_spectra', 'n_windows : int\n The number of time windows to generate.'))
def sim_spectrogram(n_windows, freq_range, aperiodic_params, periodic_params,
nlvs=0.005, freq_res=0.5, f_rotation=None, return_params=False):
"""Simulate spectrogram.
Expand Down
18 changes: 9 additions & 9 deletions specparam/tests/core/test_modutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ def test_docs_replace_param(tdocstring):

new_param = 'updated : other\n This description has been dropped in.'

ndocstring = docs_replace_param(tdocstring, 'first', new_param)
assert 'updated' in ndocstring
assert 'first' not in ndocstring
assert 'second' in ndocstring

ndocstring = docs_replace_param(tdocstring, 'second', new_param)
assert 'updated' in ndocstring
assert 'first' in ndocstring
assert 'second' not in ndocstring
ndocstring1 = docs_replace_param(tdocstring, 'first', new_param)
assert 'updated' in ndocstring1
assert 'first' not in ndocstring1
assert 'second' in ndocstring1

ndocstring2 = docs_replace_param(tdocstring, 'second', new_param)
assert 'updated' in ndocstring2
assert 'first' in ndocstring2
assert 'second' not in ndocstring2

def test_docs_append_to_section(tdocstring):

Expand Down

0 comments on commit 4f53829

Please sign in to comment.