Skip to content

Allow to customize every part of the message string #382

@fvisin

Description

@fvisin

Currently tqdm provides two mechanism to customize the message string:

  1. specify which of the predefined keys should go where, through the bar_format argument
  2. provide additional elements through the postfix argument.

It would be more powerful to let the users specify the bar_format with a mix of predefined and user-defined keys, and provide a mechanism like the set_postfix method to provide the values for the user-defined keys through a dictionary.

This is the kind of behaviour that I am imagining:

pbar = tqdm(total=num_batches,
            bar_format='Epoch {epoch:2d} - {n_fmt}/{total_fmt}{desc}{percentage}%|{bar}| '
                       '[{elapsed}<{remaining}, {rate_fmt}]')
for epoch in range(max_epochs):
    pbar.set_dict({'epoch': epoch})
    pbar.update(1)
    # ...
pbar.close()

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions