Skip to content

Fix size_str(0) returning "Unknown size" instead of "0 bytes"#8315

Open
Sreekant13 wants to merge 1 commit into
huggingface:mainfrom
Sreekant13:fix/size-str-zero-bytes
Open

Fix size_str(0) returning "Unknown size" instead of "0 bytes"#8315
Sreekant13 wants to merge 1 commit into
huggingface:mainfrom
Sreekant13:fix/size-str-zero-bytes

Conversation

@Sreekant13

Copy link
Copy Markdown

size_str uses if not size_in_bytes: to return "Unknown size", which also catches 0. But 0 is a valid size (0 bytes), and the docstring states that only None means "Unknown size". So a 0-byte size (e.g. an empty split) currently renders as "Unknown size":

>>> from datasets.utils.py_utils import size_str
>>> size_str(0)
'Unknown size'   # expected '0 bytes'

This checks size_in_bytes is None instead. Added a regression test covering None, 0, and non-zero sizes.

size_str used `if not size_in_bytes` to detect an unknown size, which also
treats 0 as unknown. But 0 is a valid size, and the docstring states that
only `None` means "Unknown size". Check `size_in_bytes is None` instead, so a
0-byte size renders as "0 bytes". Add a regression test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant