Skip to content

Commit

Permalink
Fix #1038 and #1039 (#1040)
Browse files Browse the repository at this point in the history
Resolves #1038 and #1039
  • Loading branch information
pzelasko authored Apr 24, 2023
2 parents 1b31bf2 + 1b71d2a commit 76ae055
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lhotse/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ class RecordingSet(Serializable, AlgorithmMixin):
>>> recs_24k = recs.resample(24000)
"""

def __init__(self, recordings: Mapping[str, Recording] = None) -> None:
def __init__(self, recordings: Optional[Mapping[str, Recording]] = None) -> None:
self.recordings = ifnone(recordings, {})

def __eq__(self, other: "RecordingSet") -> bool:
Expand Down
2 changes: 1 addition & 1 deletion lhotse/features/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ class FeatureSet(Serializable, AlgorithmMixin):
When a given recording/time-range/channel is unavailable, raises a KeyError.
"""

def __init__(self, features: List[Features] = None) -> None:
def __init__(self, features: Optional[List[Features]] = None) -> None:
self.features = ifnone(features, [])

def __eq__(self, other: "FeatureSet") -> bool:
Expand Down
3 changes: 2 additions & 1 deletion lhotse/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ def _maybe_open(self):
def close(self):
if self.file is not None:
self.file.close()
self.file = None

def contains(self, item: Union[str, Any]) -> bool:
return item in self
Expand Down Expand Up @@ -246,7 +247,7 @@ def open_manifest(self) -> Optional[Manifest]:
"""
if not Path(self.path).exists():
return None
if not self.file.closed:
if self.file is not None and not self.file.closed:
# If the user hasn't finished writing, make sure the latest
# changes are propagated.
self.file.flush()
Expand Down
4 changes: 3 additions & 1 deletion lhotse/supervision.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,9 @@ class SupervisionSet(Serializable, AlgorithmMixin):
>>> shuffled = sups.shuffle()
"""

def __init__(self, segments: Mapping[str, SupervisionSegment]) -> None:
def __init__(
self, segments: Optional[Mapping[str, SupervisionSegment]] = None
) -> None:
self.segments = ifnone(segments, {})

def __eq__(self, other: "SupervisionSet") -> bool:
Expand Down

0 comments on commit 76ae055

Please sign in to comment.