Skip to content

Conversation

casperdcl
Copy link
Member

@casperdcl casperdcl commented Jun 28, 2020

  • add --update
    • input passed to update(); treated as float if needed
  • add --update_to (fixes CLI input options and documentation #975)
    • input passed to self.n; treated as float if needed
  • add --null (discards stdin; no stdout)
  • improved help formatting of boolean options
  • add tests
  • update documentation/examples?
$ seq 2 2 8642086 | python -m tqdm --total 4321043 | wc -l  # old way
100%|██████████| 4321043/4321043 [00:02<00:00, 2136389.54it/s]
4321043

$ seq 2 2 8642086 | python -m tqdm --total 8642086 --update_to | wc -l  # new way
100%|██████████| 8642086.0/8642086 [00:03<00:00, 2642268.18it/s]
4321043

More advanced example (add efficient progress to any other program, even if it's written badly to spam the console with >3 million updates per second):

$ cat a.c && gcc a.c -o a.out
#include "stdio.h"
#define TOTAL 1<<23  // prints 0 to 100 with TOTAL increments
int main(){
  for(unsigned i=1; i<=TOTAL; i+=2) printf("%.0f\n", i/(double)(TOTAL)*100); }
$ ./a.out | python -m tqdm | wc -l  # old way
4194304it [00:02, 3425772.13it/s]
4194304
$ ./a.out | python -m tqdm --total 100 --update_to --unit '%' | wc -l  # new way
100%|██████████| 100.0/100 [00:02<00:00, 35.38%/s]
4194304

@casperdcl casperdcl added p3-enhancement 🔥 Much new such feature question/docs ‽ Documentation clarification candidate submodule ⊂ Periphery/subclasses to-merge ↰ Imminent c3-small 🕒 Complexity medium labels Jun 28, 2020
@casperdcl casperdcl self-assigned this Jun 28, 2020
@codecov-commenter
Copy link

codecov-commenter commented Jun 28, 2020

Codecov Report

Merging #996 into devel will increase coverage by 0.33%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##            devel     #996      +/-   ##
==========================================
+ Coverage   87.07%   87.41%   +0.33%     
==========================================
  Files          22       22              
  Lines        1354     1390      +36     
  Branches      229      236       +7     
==========================================
+ Hits         1179     1215      +36     
  Misses        151      151              
  Partials       24       24              

@casperdcl casperdcl changed the title Cli update to cli: add --update and --update_to Jun 28, 2020
@casperdcl casperdcl added this to the v5.0.0 milestone Jun 28, 2020
@casperdcl casperdcl force-pushed the devel branch 6 times, most recently from e0617fe to e7b2e0c Compare July 16, 2020 20:11
@casperdcl casperdcl linked an issue Aug 2, 2020 that may be closed by this pull request
5 tasks
@casperdcl casperdcl mentioned this pull request Sep 8, 2020
@casperdcl casperdcl merged commit 8cead19 into devel Sep 12, 2020
@casperdcl casperdcl deleted the cli-update-to branch September 12, 2020 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c3-small 🕒 Complexity medium p3-enhancement 🔥 Much new such feature question/docs ‽ Documentation clarification candidate submodule ⊂ Periphery/subclasses to-merge ↰ Imminent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI input options and documentation
2 participants