Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLN: rename _parse_file -> validate_ext, fix #123 #129

Merged
merged 1 commit into from
Jan 2, 2022
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
6 changes: 3 additions & 3 deletions src/crowsetta/notmat.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from .annotation import Annotation
from .csv import annot2csv
from .meta import Meta
from .validation import _parse_file
from .validation import validate_ext


def notmat2annot(annot_path,
Expand Down Expand Up @@ -56,7 +56,7 @@ def notmat2annot(annot_path,
due to floating point error, e.g. when loading .not.mat files and then sending them to
a csv file, the result should be the same on Windows and Linux
"""
annot_path = _parse_file(annot_path, extension='.not.mat')
annot_path = validate_ext(annot_path, extension='.not.mat')

if abspath and basename:
raise ValueError('abspath and basename arguments cannot both be set to True, '
Expand Down Expand Up @@ -123,7 +123,7 @@ def notmat2csv(annot_path, csv_filename, abspath=False, basename=False):
-------
None
"""
annot_path = _parse_file(annot_path, extension='.not.mat')
annot_path = validate_ext(annot_path, extension='.not.mat')

if abspath and basename:
raise ValueError('abspath and basename arguments cannot both be set to True, '
Expand Down
6 changes: 3 additions & 3 deletions src/crowsetta/phn.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .annotation import Annotation
from .csv import annot2csv
from .meta import Meta
from .validation import _parse_file
from .validation import validate_ext


def phn2annot(annot_path,
Expand Down Expand Up @@ -56,7 +56,7 @@ def phn2annot(annot_path,
"""
# note multiple extensions, both all-uppercase and all-lowercase `.phn` exist,
# depending on which version of TIMIT dataset you have
annot_path = _parse_file(annot_path, extension=('.phn', '.PHN'))
annot_path = validate_ext(annot_path, extension=('.phn', '.PHN'))

if abspath and basename:
raise ValueError('abspath and basename arguments cannot both be set to True, '
Expand Down Expand Up @@ -145,7 +145,7 @@ def phn2csv(annot_path, csv_filename, abspath=False, basename=False):
-------
None
"""
annot_path = _parse_file(annot_path, extension=('.phn', '.PHN'))
annot_path = validate_ext(annot_path, extension=('.phn', '.PHN'))

if abspath and basename:
raise ValueError('abspath and basename arguments cannot both be set to True, '
Expand Down
6 changes: 3 additions & 3 deletions src/crowsetta/textgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from .csv import annot2csv
from .meta import Meta
from .sequence import Sequence
from .validation import _parse_file
from .validation import validate_ext


def textgrid2annot(annot_path,
Expand Down Expand Up @@ -61,7 +61,7 @@ def textgrid2annot(annot_path,
each Interval in the first IntervalTier in a TextGrid file
will become one segment in a sequence.
"""
annot_path = _parse_file(annot_path, extension='.TextGrid')
annot_path = validate_ext(annot_path, extension='.TextGrid')
annots = []
for a_textgrid in annot_path:
tg = TextGrid.fromFile(a_textgrid)
Expand Down Expand Up @@ -139,7 +139,7 @@ def textgrid2csv(annot_path, csv_filename, abspath=False, basename=False):
-------
None
"""
annot_path = _parse_file(annot_path, extension='.TextGrid')
annot_path = validate_ext(annot_path, extension='.TextGrid')

if abspath and basename:
raise ValueError('abspath and basename arguments cannot both be set to True, '
Expand Down
2 changes: 1 addition & 1 deletion src/crowsetta/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def column_or_row_or_1d(y):
raise ValueError("bad input shape {0}".format(shape))


def _parse_file(file, extension):
def validate_ext(file, extension):
""""check that all files have valid extensions,
convert into a list that can be iterated over

Expand Down
2 changes: 1 addition & 1 deletion src/crowsetta/yarden.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from .csv import annot2csv
from .meta import Meta
from .sequence import Sequence
from .validation import _parse_file
from .validation import validate_ext


def _cast_to_arr(val):
Expand Down