Skip to content

Commit

Permalink
Merge pull request #80 from fgnt/fix-numpy20
Browse files Browse the repository at this point in the history
Fixes for numpy 2
  • Loading branch information
thequilo authored Jun 26, 2024
2 parents 1854588 + d441025 commit d96999c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
24 changes: 17 additions & 7 deletions meeteval/wer/wer/time_constrained.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def get_pseudo_word_level_timings(t: SegLST, strategy: str) -> SegLST:
- `'none`' or `None`: Do not estimate word-level timings but assume
that the provided timings are already given on a word level.
>>> from IPython.lib.pretty import pprint
>>> from paderbox.utils.pretty import pprint
>>> from meeteval.io.seglst import SegLST
>>> s = SegLST([{'words': 'abc b', 'start_time': 0, 'end_time': 4}, {'words': 'c d e f', 'start_time': 4, 'end_time': 8}])
>>> pprint(get_pseudo_word_level_timings(s, 'full_segment'))
Expand Down Expand Up @@ -499,18 +499,28 @@ def sort_and_validate(segments: SegLST, sort, pseudo_word_level_timing, name, wa
pseudo_word_level_timing:
name:
>>> from paderbox.utils.pretty import pprint
>>> segments = SegLST([{'words': 'c d', 'start_time': 1, 'end_time': 3}, {'words': 'a b', 'start_time': 0, 'end_time': 3}])
>>> sort_and_validate(segments, True, 'character_based', 'test')
Traceback (most recent call last):
...
ValueError: The order of word-level timings contradicts the segment-level order in test: 2 of 4 times.
Consider setting sort to False or "segment" or "word".
>>> sort_and_validate(segments, False, 'character_based', 'test')
SegLST(segments=[{'words': 'c', 'start_time': 1.0, 'end_time': 2.0}, {'words': 'd', 'start_time': 2.0, 'end_time': 3.0}, {'words': 'a', 'start_time': 0.0, 'end_time': 1.5}, {'words': 'b', 'start_time': 1.5, 'end_time': 3.0}])
>>> sort_and_validate(segments, 'segment', 'character_based', 'test')
SegLST(segments=[{'words': 'a', 'start_time': 0.0, 'end_time': 1.5}, {'words': 'b', 'start_time': 1.5, 'end_time': 3.0}, {'words': 'c', 'start_time': 1.0, 'end_time': 2.0}, {'words': 'd', 'start_time': 2.0, 'end_time': 3.0}])
>>> sort_and_validate(segments, 'word', 'character_based', 'test')
SegLST(segments=[{'words': 'a', 'start_time': 0.0, 'end_time': 1.5}, {'words': 'c', 'start_time': 1.0, 'end_time': 2.0}, {'words': 'b', 'start_time': 1.5, 'end_time': 3.0}, {'words': 'd', 'start_time': 2.0, 'end_time': 3.0}])
>>> pprint(sort_and_validate(segments, False, 'character_based', 'test'))
SegLST([{'words': 'c', 'start_time': 1.0, 'end_time': 2.0},
{'words': 'd', 'start_time': 2.0, 'end_time': 3.0},
{'words': 'a', 'start_time': 0.0, 'end_time': 1.5},
{'words': 'b', 'start_time': 1.5, 'end_time': 3.0}])
>>> pprint(sort_and_validate(segments, 'segment', 'character_based', 'test'))
SegLST([{'words': 'a', 'start_time': 0.0, 'end_time': 1.5},
{'words': 'b', 'start_time': 1.5, 'end_time': 3.0},
{'words': 'c', 'start_time': 1.0, 'end_time': 2.0},
{'words': 'd', 'start_time': 2.0, 'end_time': 3.0}])
>>> pprint(sort_and_validate(segments, 'word', 'character_based', 'test'))
SegLST([{'words': 'a', 'start_time': 0.0, 'end_time': 1.5},
{'words': 'c', 'start_time': 1.0, 'end_time': 2.0},
{'words': 'b', 'start_time': 1.5, 'end_time': 3.0},
{'words': 'd', 'start_time': 2.0, 'end_time': 3.0}])
"""
if sort not in (True, False, 'segment', 'word'):
raise ValueError(
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
'hypothesis',
'coverage',
'pytest-cov',
'ipython', # IPython.lib.pretty.pprint
'paderbox', # paderbox.utils.pretty.pprint
*extras_require['cli'],
]
extras_require['all'] = [
Expand Down Expand Up @@ -118,6 +118,7 @@
packages=find_packages(exclude=['contrib', 'docs', 'tests*']),
install_requires=[
'kaldialign',
'numpy',
'scipy', # scipy.optimize.linear_sum_assignment
"typing_extensions; python_version<'3.8'", # Missing Literal in py37
"cached_property; python_version<'3.8'", # Missing functools.cached_property in py37
Expand Down

0 comments on commit d96999c

Please sign in to comment.