Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SI units calculation and introduce OptionUseIECUnits() #167

Merged
merged 3 commits into from Nov 6, 2023
Merged

Fix SI units calculation and introduce OptionUseIECUnits() #167

merged 3 commits into from Nov 6, 2023

Conversation

edigaryev
Copy link
Contributor

Problem: currently progressbar uses SI units by default:

sizes := []string{" B", " kB", " MB", " GB", " TB", " PB", " EB"}

...but calculates them with base 1024, which is not correct and should be 1000 instead.

It's also not possible to choose which the units to use, e.g. the github.com/dustin/go-humanize package, for example, allows one to either use Bytes() or IBytes().

Solution: fix SI unit base and introduce OptionUseIECUnits() option to enable IEC units like KiB, MiB, etc.

@edigaryev
Copy link
Contributor Author

@schollz would you mind taking a look at this?

@schollz
Copy link
Owner

schollz commented Nov 5, 2023

It looks like tests are failing?

@edigaryev
Copy link
Contributor Author

TestBarSmallBytes: use proper SI units

Indeed, fixed in ba1eaf1.

@schollz
Copy link
Owner

schollz commented Nov 6, 2023

Great, thanks!!

@schollz schollz merged commit c4499b7 into schollz:main Nov 6, 2023
1 check passed
@edigaryev edigaryev deleted the fix-humanize-bytes branch November 6, 2023 17:14
kodiakhq bot pushed a commit to cloudquery/plugin-pb-go that referenced this pull request Apr 1, 2024
…#289)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [github.com/schollz/progressbar/v3](https://togithub.com/schollz/progressbar) | require | minor | `v3.13.1` -> `v3.14.2` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency Dashboard for more information.

---

### Release Notes

<details>
<summary>schollz/progressbar (github.com/schollz/progressbar/v3)</summary>

### [`v3.14.2`](https://togithub.com/schollz/progressbar/releases/tag/v3.14.2)

[Compare Source](https://togithub.com/schollz/progressbar/compare/v3.14.1...v3.14.2)

#### What's Changed

-   Add pacman example gif by [@&#8203;OlegChuev](https://togithub.com/OlegChuev) in [schollz/progressbar#174
-   📝docs: Add a library definition for ansi by [@&#8203;eogns47](https://togithub.com/eogns47) in [schollz/progressbar#173
-   Add more properties to State by [@&#8203;treuherz](https://togithub.com/treuherz) in [schollz/progressbar#170
-   fix: Protect RenderBlank() and IsFinished() with the lock by [@&#8203;RichieSams](https://togithub.com/RichieSams) in [schollz/progressbar#164

#### New Contributors

-   [@&#8203;OlegChuev](https://togithub.com/OlegChuev) made their first contribution in [schollz/progressbar#174
-   [@&#8203;eogns47](https://togithub.com/eogns47) made their first contribution in [schollz/progressbar#173
-   [@&#8203;treuherz](https://togithub.com/treuherz) made their first contribution in [schollz/progressbar#170
-   [@&#8203;RichieSams](https://togithub.com/RichieSams) made their first contribution in [schollz/progressbar#164

**Full Changelog**: schollz/progressbar@v3.14.1...v3.14.2

### [`v3.14.1`](https://togithub.com/schollz/progressbar/releases/tag/v3.14.1)

[Compare Source](https://togithub.com/schollz/progressbar/compare/v3.14.0...v3.14.1)

(pi release)

**Full Changelog**: schollz/progressbar@v3.14.0...v3.14.1

### [`v3.14.0`](https://togithub.com/schollz/progressbar/releases/tag/v3.14.0)

[Compare Source](https://togithub.com/schollz/progressbar/compare/v3.13.1...v3.14.0)

#### What's Changed

-   change library to get rune width by [@&#8203;tukaelu](https://togithub.com/tukaelu) in [schollz/progressbar#169
-   Fix SI units calculation and introduce OptionUseIECUnits() by [@&#8203;edigaryev](https://togithub.com/edigaryev) in [schollz/progressbar#167

#### New Contributors

-   [@&#8203;tukaelu](https://togithub.com/tukaelu) made their first contribution in [schollz/progressbar#169
-   [@&#8203;edigaryev](https://togithub.com/edigaryev) made their first contribution in [schollz/progressbar#167

**Full Changelog**: schollz/progressbar@v3.13.1...v3.14.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 4am on the first day of the month" (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://togithub.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNzguMCIsInVwZGF0ZWRJblZlciI6IjM3LjI3OC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJhdXRvbWVyZ2UiXX0=-->
inquestruss pushed a commit to boatkit-io/n2k that referenced this pull request May 7, 2024
…#25)

[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[github.com/schollz/progressbar/v3](https://togithub.com/schollz/progressbar)
| `v3.13.1` -> `v3.14.2` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fschollz%2fprogressbar%2fv3/v3.14.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fschollz%2fprogressbar%2fv3/v3.14.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fschollz%2fprogressbar%2fv3/v3.13.1/v3.14.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fschollz%2fprogressbar%2fv3/v3.13.1/v3.14.2?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>schollz/progressbar
(github.com/schollz/progressbar/v3)</summary>

###
[`v3.14.2`](https://togithub.com/schollz/progressbar/releases/tag/v3.14.2)

[Compare
Source](https://togithub.com/schollz/progressbar/compare/v3.14.1...v3.14.2)

#### What's Changed

- Add pacman example gif by
[@&#8203;OlegChuev](https://togithub.com/OlegChuev) in
[schollz/progressbar#174
- 📝docs: Add a library definition for ansi by
[@&#8203;eogns47](https://togithub.com/eogns47) in
[schollz/progressbar#173
- Add more properties to State by
[@&#8203;treuherz](https://togithub.com/treuherz) in
[schollz/progressbar#170
- fix: Protect RenderBlank() and IsFinished() with the lock by
[@&#8203;RichieSams](https://togithub.com/RichieSams) in
[schollz/progressbar#164

#### New Contributors

- [@&#8203;OlegChuev](https://togithub.com/OlegChuev) made their first
contribution in
[schollz/progressbar#174
- [@&#8203;eogns47](https://togithub.com/eogns47) made their first
contribution in
[schollz/progressbar#173
- [@&#8203;treuherz](https://togithub.com/treuherz) made their first
contribution in
[schollz/progressbar#170
- [@&#8203;RichieSams](https://togithub.com/RichieSams) made their first
contribution in
[schollz/progressbar#164

**Full Changelog**:
schollz/progressbar@v3.14.1...v3.14.2

###
[`v3.14.1`](https://togithub.com/schollz/progressbar/releases/tag/v3.14.1)

[Compare
Source](https://togithub.com/schollz/progressbar/compare/v3.14.0...v3.14.1)

(pi release)

**Full Changelog**:
schollz/progressbar@v3.14.0...v3.14.1

###
[`v3.14.0`](https://togithub.com/schollz/progressbar/releases/tag/v3.14.0)

[Compare
Source](https://togithub.com/schollz/progressbar/compare/v3.13.1...v3.14.0)

#### What's Changed

- change library to get rune width by
[@&#8203;tukaelu](https://togithub.com/tukaelu) in
[schollz/progressbar#169
- Fix SI units calculation and introduce OptionUseIECUnits() by
[@&#8203;edigaryev](https://togithub.com/edigaryev) in
[schollz/progressbar#167

#### New Contributors

- [@&#8203;tukaelu](https://togithub.com/tukaelu) made their first
contribution in
[schollz/progressbar#169
- [@&#8203;edigaryev](https://togithub.com/edigaryev) made their first
contribution in
[schollz/progressbar#167

**Full Changelog**:
schollz/progressbar@v3.13.1...v3.14.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/boatkit-io/n2k).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40Ni4wIiwidXBkYXRlZEluVmVyIjoiMzcuMjAwLjAiLCJ0YXJnZXRCcmFuY2giOiJtYWluIn0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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.

None yet

2 participants