8000 `format_interval` displays wrong output for negative intervals · Issue #1650 · tqdm/tqdm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

format_interval displays wrong output for negative intervals #1650

New issue
8000

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

Open
5 of 6 tasks
DavidBuchanan314 opened this issue Feb 2, 2025 · 1 comment
Open
5 of 6 tasks

Comments

@DavidBuchanan314
Copy link
DavidBuchanan314 commented Feb 2, 2025
  • I have marked all applicable categories:
    • exception-raising bug
    • visual output bug
  • I have visited the source website, and in particular
    read the known issues
  • I have searched through the issue tracker for duplicates
  • I have mentioned version numbers, operating system and
    environment, where applicable

Demonstration:

import tqdm, sys

print(tqdm.__version__, sys.version, sys.platform)
# 4.66.1 3.12.8 (main, Dec  6 2024, 00:00:00) [GCC 14.2.1 20240912 (Red Hat 14.2.1-3)] linux

print(tqdm.tqdm.format_interval(-1)) # expected: "-00:01", actually "-1:59:59"
print(tqdm.tqdm.format_interval(-100000)) # expected: "-27:46:40", actually "-28:13:20"

Arguably I shouldn't expect it to work at all for negative intervals, but if so it would be preferable to raise an exception than to produce incorrect outputs.

@DavidBuchanan314
Copy link
Author
DavidBuchanan314 commented Feb 2, 2025

as a workaround, one can do something like this

def format_interval_fixed(t: int) -> str:
    sign = "-" if t < 0 else ""
    return sign + tqdm.tqdm.format_interval(abs(t))

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

No branches or pull requests

1 participant
0