diff --git a/audb/core/dependencies.py b/audb/core/dependencies.py index fb7171c6..e6a23b2d 100644 --- a/audb/core/dependencies.py +++ b/audb/core/dependencies.py @@ -224,7 +224,7 @@ def archive(self, file: str) -> str: """ return self[file][define.DependField.ARCHIVE] - def bit_depth(self, file: str) -> typing.Optional[int]: + def bit_depth(self, file: str) -> int: r"""Bit depth of media file. Args: @@ -234,9 +234,9 @@ def bit_depth(self, file: str) -> typing.Optional[int]: bit depth """ - return self[file][define.DependField.BIT_DEPTH] or None + return self[file][define.DependField.BIT_DEPTH] - def channels(self, file: str) -> typing.Optional[int]: + def channels(self, file: str) -> int: r"""Number of channels of media file. Args: @@ -246,7 +246,7 @@ def channels(self, file: str) -> typing.Optional[int]: number of channels """ - return self[file][define.DependField.CHANNELS] or None + return self[file][define.DependField.CHANNELS] def checksum(self, file: str) -> str: r"""Checksum of file. @@ -260,7 +260,7 @@ def checksum(self, file: str) -> str: """ return self[file][define.DependField.CHECKSUM] - def duration(self, file: str) -> typing.Optional[float]: + def duration(self, file: str) -> float: r"""Duration of file. Args: @@ -270,7 +270,7 @@ def duration(self, file: str) -> typing.Optional[float]: duration in seconds """ - return self[file][define.DependField.DURATION] or None + return self[file][define.DependField.DURATION] def format(self, file: str) -> str: r"""Format of file. @@ -337,7 +337,7 @@ def remove(self, file: str): """ self._data[file][define.DependField.REMOVED] = 1 - def sampling_rate(self, file: str) -> typing.Optional[int]: + def sampling_rate(self, file: str) -> int: r"""Sampling rate of media file. Args: @@ -347,7 +347,7 @@ def sampling_rate(self, file: str) -> typing.Optional[int]: sampling rate in Hz """ - return self[file][define.DependField.SAMPLING_RATE] or None + return self[file][define.DependField.SAMPLING_RATE] def save(self, path: str): r"""Write dependencies to CSV file. diff --git a/audb/core/info.py b/audb/core/info.py index 5601b977..02785c74 100644 --- a/audb/core/info.py +++ b/audb/core/info.py @@ -52,7 +52,6 @@ def bit_depths( return set( [ deps.bit_depth(file) for file in deps.media - if deps.bit_depth(file) ] ) @@ -76,7 +75,6 @@ def channels( return set( [ deps.channels(file) for file in deps.media - if deps.channels(file) ] ) @@ -117,7 +115,7 @@ def duration( """ deps = dependencies(name, version=version) return pd.to_timedelta( - deps()['duration'].sum(), + sum([deps.duration(file) for file in deps.media]), unit='s', ) @@ -333,7 +331,6 @@ def sampling_rates( return set( [ deps.sampling_rate(file) for file in deps.media - if deps.sampling_rate(file) ] )