Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions fooof/core/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def fpath(file_path, file_name):

Parameters
----------
file_path : str or None
file_path : Path or str or None
Path to the directory where the file is located.
file_name : str
Name of the file.
Expand Down Expand Up @@ -71,7 +71,7 @@ def save_fm(fm, file_name, file_path=None, append=False,
Object to save data from.
file_name : str or FileObject
File to save data to.
file_path : str, optional
file_path : Path or str, optional
Path to directory to save to. If None, saves to current directory.
append : bool, optional, default: False
Whether to append to an existing file, if available.
Expand Down Expand Up @@ -129,7 +129,7 @@ def save_fg(fg, file_name, file_path=None, append=False,
Object to save data from.
file_name : str or FileObject
File to save data to.
file_path : str, optional
file_path : Path or str, optional
Path to directory to load from. If None, loads from current directory.
append : bool, optional, default: False
Whether to append to an existing file, if available.
Expand Down Expand Up @@ -175,7 +175,7 @@ def load_json(file_name, file_path):
----------
file_name : str or FileObject
File to load data from.
file_path : str
file_path : Path or str
Path to directory to load from.

Returns
Expand Down Expand Up @@ -204,7 +204,7 @@ def load_jsonlines(file_name, file_path):
----------
file_name : str
File to load data from.
file_path : str
file_path : Path or str
Path to directory from load from.

Yields
Expand Down
4 changes: 2 additions & 2 deletions fooof/core/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def save_report_fm(fm, file_name, file_path=None, plt_log=False, add_settings=Tr
Object with results from fitting a power spectrum.
file_name : str
Name to give the saved out file.
file_path : str, optional
file_path : Path or str, optional
Path to directory to save to. If None, saves to current directory.
plt_log : bool, optional, default: False
Whether or not to plot the frequency axis in log space.
Expand Down Expand Up @@ -83,7 +83,7 @@ def save_report_fg(fg, file_name, file_path=None, add_settings=True):
Object with results from fitting a group of power spectra.
file_name : str
Name to give the saved out file.
file_path : str, optional
file_path : Path or str, optional
Path to directory to save to. If None, saves to current directory.
add_settings : bool, optional, default: True
Whether to add a print out of the model settings to the end of the report.
Expand Down
2 changes: 1 addition & 1 deletion fooof/objs/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ def load(self, file_name, file_path=None, regenerate=True):
----------
file_name : str or FileObject
File to load data from.
file_path : str or None, optional
file_path : Path or str, optional
Path to directory to load from. If None, loads from current directory.
regenerate : bool, optional, default: True
Whether to regenerate the model fit from the loaded data, if data is available.
Expand Down
4 changes: 2 additions & 2 deletions fooof/objs/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def load(self, file_name, file_path=None):
----------
file_name : str
File to load data from.
file_path : str, optional
file_path : Path or str, optional
Path to directory to load from. If None, loads from current directory.
"""

Expand Down Expand Up @@ -533,7 +533,7 @@ def save_model_report(self, index, file_name, file_path=None, plt_log=False,
Index of the model fit to save out.
file_name : str
Name to give the saved out file.
file_path : str, optional
file_path : Path or str, optional
Path to directory to save to. If None, saves to current directory.
plt_log : bool, optional, default: False
Whether or not to plot the frequency axis in log space.
Expand Down
2 changes: 1 addition & 1 deletion fooof/plts/fg.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def plot_fg(fg, save_fig=False, file_name=None, file_path=None, **plot_kwargs):
Whether to save out a copy of the plot.
file_name : str, optional
Name to give the saved out file.
file_path : str, optional
file_path : Path or str, optional
Path to directory to save to. If None, saves to current directory.

Raises
Expand Down
2 changes: 1 addition & 1 deletion fooof/plts/fm.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def plot_fm(fm, plot_peaks=None, plot_aperiodic=True, plt_log=False, add_legend=
Whether to save out a copy of the plot.
file_name : str, optional
Name to give the saved out file.
file_path : str, optional
file_path : Path or str, optional
Path to directory to save to. If None, saves to current directory.
ax : matplotlib.Axes, optional
Figure axes upon which to plot.
Expand Down
2 changes: 1 addition & 1 deletion fooof/plts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def save_figure(file_name, file_path=None, close=False, **save_kwargs):
----------
file_name : str
File name for the figure file to save out.
file_path : str or Path
file_path : Path or str
Path for where to save out the figure to.
close : bool, optional, default: False
Whether to close the plot after saving.
Expand Down
2 changes: 2 additions & 0 deletions fooof/tests/core/test_io.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Tests for fooof.core.io."""

import os
from pathlib import Path

from fooof.core.items import OBJ_DESC

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

assert fpath(None, 'data.json') == 'data.json'
assert fpath('/path/', 'data.json') == '/path/data.json'
assert fpath(Path('/path/'), 'data.json') == '/path/data.json'

def test_save_fm_str(tfm):
"""Check saving fm data, with file specifiers as strings."""
Expand Down
15 changes: 10 additions & 5 deletions fooof/utils/download.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
"""Functions and utilities for downloading example data for fooof."""

import os
from pathlib import Path
from urllib.request import urlretrieve

import numpy as np

from fooof.core.io import fpath

###################################################################################################
###################################################################################################

Expand All @@ -15,7 +18,7 @@ def check_data_folder(folder):

Parameters
----------
folder : str
folder : Path or str
Name of the folder to check and create if missing.
"""

Expand All @@ -30,11 +33,13 @@ def check_data_file(filename, folder, url=DATA_URL):
----------
filename : str
Name of the data file to check and download if missing.
folder : str
folder : Path or str
Name of the folder to save the datafile to.
url : str, optional
The URL to download the data file from.
"""

filepath = os.path.join(folder, filename)
filepath = fpath(folder, filename)

if not os.path.isfile(filepath):
urlretrieve(url + filename, filename=filepath)
Expand All @@ -47,7 +52,7 @@ def fetch_fooof_data(filename, folder='data', url=DATA_URL):
----------
filename : str
Name of the data file to download.
folder : str, optional
folder : Path or str, optional
Name of the folder to save the datafile to.
url : str, optional
The URL to download the data file from.
Expand All @@ -69,7 +74,7 @@ def load_fooof_data(filename, folder='data', url=DATA_URL):
----------
filename : str
Name of the data file to download.
folder : str, optional
folder : Path or str, optional
Name of the folder to save the datafile to.
url : str, optional
The URL to download the data file from.
Expand Down
4 changes: 2 additions & 2 deletions fooof/utils/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def load_fooof(file_name, file_path=None, regenerate=True):
----------
file_name : str or FileObject
File to load the data from.
file_path : str or None, optional
file_path : Path or str, optional
Path to directory to load from. If None, loads from current directory.
regenerate : bool, optional, default: True
Whether to regenerate the model fit from the loaded data, if data is available.
Expand Down Expand Up @@ -38,7 +38,7 @@ def load_fooofgroup(file_name, file_path=None):
----------
file_name : str
File to load data data.
file_path : str, optional
file_path : Path or str, optional
Path to directory to load from. If None, loads from current directory.

Returns
Expand Down