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

Function to set tqdm.n #1586

Open
5 of 6 tasks
sigvaldm opened this issue May 29, 2024 · 1 comment
Open
5 of 6 tasks

Function to set tqdm.n #1586

sigvaldm opened this issue May 29, 2024 · 1 comment

Comments

@sigvaldm
Copy link

  • I have marked all applicable categories:
    • documentation request (i.e. "X is missing from the documentation." If instead I want to ask "how to use X?" I understand StackOverflow#tqdm is more appropriate)
    • new feature request
  • 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:
    import tqdm, sys
    print(tqdm.__version__, sys.version, sys.platform)
    4.66.4 3.12.3 | packaged by Anaconda, Inc. | (main, May 6 2024, 19:46:43) [GCC 11.2.0] linux

Measuring progress is not always a matter of counting items. It can also refer to some floating point number that increases (hopefully somewhat linearly) with time. It appears the tqdm.update() method is the way tqdm supports this, which in that case takes a delta of a floating point number. Adding up such deltas lead to floating point errors causing the TqdmWarning: clamping frac to range [0, 1] (see issue #999). There ought to be a method which sets tqdm.n directly, because often relevant applications will have the value of the floating point number itself, instead of just the deltas. This also lets the user avoid the warning.

@sigvaldm
Copy link
Author

Edit: more precisely, the deltas may add up to exceed the threshold of 0.5 which I see in Tqdm's source code for reasons tqdm has no control over. Hence, if having a funciton to set tqdm.n, the user could control clamping manually.

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