KEMBAR78
Minor fixes/improvements in `convert_file_size_to_int` by mariosasko · Pull Request #16891 · huggingface/transformers · GitHub
Skip to content

Conversation

@mariosasko
Copy link
Contributor

Fix convert_file_size_to_int's docstring example and the GB str to int conversion (per this comment by @lhoestq).

@mariosasko mariosasko requested a review from sgugger April 22, 2022 14:03
return int(size[:-2]) * (10**9)
if size.endswith("Gb"):
# gigabits
return int(size[:-2]) * (10**9 >> 3)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand this. This should be // 8 as 1 gigabyte = 8 gigabits. Also if we start supporting this, it should be the same for kilos and megas.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand this. This should be // 8 as 1 gigabyte = 8 gigabits.

Yes, >> 3 does the same as // 8.

Also if we start supporting this, it should be the same for kilos and megas.

IMO it makes sense to be as precise as possible.

P.S. I did the same for kilos and megas.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Apr 22, 2022

The documentation is not available anymore as the PR was closed or merged.

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot, LGTM!

@mariosasko mariosasko merged commit 9fa8817 into main Apr 22, 2022
@mariosasko mariosasko deleted the convert-file-size-to-int-gb-fix branch April 22, 2022 14:54
elusenji pushed a commit to elusenji/transformers that referenced this pull request Jun 12, 2022
…6891)

* Minor improvements to `convert_file_size_to_int`

* Add <unit>bit version to kilos and megas

* Minor fix
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.

3 participants