Skip to content

Commit

Permalink
Merge pull request #129 from NickleDave/rename-parse-file-validate-ext
Browse files Browse the repository at this point in the history
CLN: rename `_parse_file` -> `validate_ext`, fix #123
  • Loading branch information
NickleDave authored Jan 2, 2022
2 parents 8a55997 + f1eb991 commit bfde7f0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
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

0 comments on commit bfde7f0

Please sign in to comment.