Skip to content

Commit

Permalink
Fix seglst format check
Browse files Browse the repository at this point in the history
  • Loading branch information
thequilo committed Jan 25, 2024
1 parent 1d3c9ac commit 0a3603c
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions meeteval/io/seglst.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,19 @@ def fix_floats(s):

# Check if the first and last entry have the correct format. We here
# require that the "session_id" key is present in all segments.
if (
loaded
and not isinstance(loaded[0], dict) and 'session_id' in loaded[0]
and not isinstance(loaded[-1], dict) and 'session_id' in loaded[-1]
):
raise ValueError(
f'Invalid JSON format for SegLST: Expected a list of segments '
f'(as dicts), but found a list of {type(loaded[0])}.'
)
if loaded:
if (
isinstance(loaded[0], dict)
and isinstance(loaded[-1], dict)
and 'session_id' in loaded[0]
and 'session_id' in loaded[-1]
):
pass
else:
raise ValueError(
f'Invalid JSON format for SegLST: Expected a list of segments '
f'(as dicts), but found a list of {type(loaded[0])}.'
)

return cls([fix_floats(s) for s in loaded])

Expand Down

0 comments on commit 0a3603c

Please sign in to comment.