Skip to content

Commit 5c421b6

Browse files
committed
test & add explicit path support
1 parent 172101a commit 5c421b6

File tree

9 files changed

+17
-15
lines changed

9 files changed

+17
-15
lines changed

fooof/core/io.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def fpath(file_path, file_name):
3838
3939
Parameters
4040
----------
41-
file_path : str or None
41+
file_path : Path or str or None
4242
Path to the directory where the file is located.
4343
file_name : str
4444
Name of the file.
@@ -71,7 +71,7 @@ def save_fm(fm, file_name, file_path=None, append=False,
7171
Object to save data from.
7272
file_name : str or FileObject
7373
File to save data to.
74-
file_path : str, optional
74+
file_path : Path or str, optional
7575
Path to directory to save to. If None, saves to current directory.
7676
append : bool, optional, default: False
7777
Whether to append to an existing file, if available.
@@ -129,7 +129,7 @@ def save_fg(fg, file_name, file_path=None, append=False,
129129
Object to save data from.
130130
file_name : str or FileObject
131131
File to save data to.
132-
file_path : str, optional
132+
file_path : Path or str, optional
133133
Path to directory to load from. If None, loads from current directory.
134134
append : bool, optional, default: False
135135
Whether to append to an existing file, if available.
@@ -175,7 +175,7 @@ def load_json(file_name, file_path):
175175
----------
176176
file_name : str or FileObject
177177
File to load data from.
178-
file_path : str
178+
file_path : Path or str
179179
Path to directory to load from.
180180
181181
Returns
@@ -204,7 +204,7 @@ def load_jsonlines(file_name, file_path):
204204
----------
205205
file_name : str
206206
File to load data from.
207-
file_path : str
207+
file_path : Path or str
208208
Path to directory from load from.
209209
210210
Yields

fooof/core/reports.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def save_report_fm(fm, file_name, file_path=None, plt_log=False, add_settings=Tr
3131
Object with results from fitting a power spectrum.
3232
file_name : str
3333
Name to give the saved out file.
34-
file_path : str, optional
34+
file_path : Path or str, optional
3535
Path to directory to save to. If None, saves to current directory.
3636
plt_log : bool, optional, default: False
3737
Whether or not to plot the frequency axis in log space.
@@ -83,7 +83,7 @@ def save_report_fg(fg, file_name, file_path=None, add_settings=True):
8383
Object with results from fitting a group of power spectra.
8484
file_name : str
8585
Name to give the saved out file.
86-
file_path : str, optional
86+
file_path : Path or str, optional
8787
Path to directory to save to. If None, saves to current directory.
8888
add_settings : bool, optional, default: True
8989
Whether to add a print out of the model settings to the end of the report.

fooof/objs/fit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ def load(self, file_name, file_path=None, regenerate=True):
671671
----------
672672
file_name : str or FileObject
673673
File to load data from.
674-
file_path : str or None, optional
674+
file_path : Path or str, optional
675675
Path to directory to load from. If None, loads from current directory.
676676
regenerate : bool, optional, default: True
677677
Whether to regenerate the model fit from the loaded data, if data is available.

fooof/objs/group.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def load(self, file_name, file_path=None):
403403
----------
404404
file_name : str
405405
File to load data from.
406-
file_path : str, optional
406+
file_path : Path or str, optional
407407
Path to directory to load from. If None, loads from current directory.
408408
"""
409409

@@ -533,7 +533,7 @@ def save_model_report(self, index, file_name, file_path=None, plt_log=False,
533533
Index of the model fit to save out.
534534
file_name : str
535535
Name to give the saved out file.
536-
file_path : str, optional
536+
file_path : Path or str, optional
537537
Path to directory to save to. If None, saves to current directory.
538538
plt_log : bool, optional, default: False
539539
Whether or not to plot the frequency axis in log space.

fooof/plts/fg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def plot_fg(fg, save_fig=False, file_name=None, file_path=None, **plot_kwargs):
3131
Whether to save out a copy of the plot.
3232
file_name : str, optional
3333
Name to give the saved out file.
34-
file_path : str, optional
34+
file_path : Path or str, optional
3535
Path to directory to save to. If None, saves to current directory.
3636
3737
Raises

fooof/plts/fm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def plot_fm(fm, plot_peaks=None, plot_aperiodic=True, plt_log=False, add_legend=
4747
Whether to save out a copy of the plot.
4848
file_name : str, optional
4949
Name to give the saved out file.
50-
file_path : str, optional
50+
file_path : Path or str, optional
5151
Path to directory to save to. If None, saves to current directory.
5252
ax : matplotlib.Axes, optional
5353
Figure axes upon which to plot.

fooof/plts/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def save_figure(file_name, file_path=None, close=False, **save_kwargs):
211211
----------
212212
file_name : str
213213
File name for the figure file to save out.
214-
file_path : str or Path
214+
file_path : Path or str
215215
Path for where to save out the figure to.
216216
close : bool, optional, default: False
217217
Whether to close the plot after saving.

fooof/tests/core/test_io.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Tests for fooof.core.io."""
22

33
import os
4+
from pathlib import Path
45

56
from fooof.core.items import OBJ_DESC
67

@@ -26,6 +27,7 @@ def test_fpath():
2627

2728
assert fpath(None, 'data.json') == 'data.json'
2829
assert fpath('/path/', 'data.json') == '/path/data.json'
30+
assert fpath(Path('/path/'), 'data.json') == '/path/data.json'
2931

3032
def test_save_fm_str(tfm):
3133
"""Check saving fm data, with file specifiers as strings."""

fooof/utils/io.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def load_fooof(file_name, file_path=None, regenerate=True):
1010
----------
1111
file_name : str or FileObject
1212
File to load the data from.
13-
file_path : str or None, optional
13+
file_path : Path or str, optional
1414
Path to directory to load from. If None, loads from current directory.
1515
regenerate : bool, optional, default: True
1616
Whether to regenerate the model fit from the loaded data, if data is available.
@@ -38,7 +38,7 @@ def load_fooofgroup(file_name, file_path=None):
3838
----------
3939
file_name : str
4040
File to load data data.
41-
file_path : str, optional
41+
file_path : Path or str, optional
4242
Path to directory to load from. If None, loads from current directory.
4343
4444
Returns

0 commit comments

Comments
 (0)