Skip to content

Do we need a tenumerate fucntion? #840

@TezRomacH

Description

@TezRomacH

Hi! We use the tqdm in Catalyst a lot, thank you for this library.

My frequent case is to use tqdm together with enumerate. I keep forgetting in which order to pass what, according to this:

Wrapping enumerated iterables: use enumerate(tqdm(...)) instead of tqdm(enumerate(...)). The same applies to numpy.ndenumerate. This is because enumerate functions tend to hide the length of iterables. tqdm does not.

My suggestion is very simple, lets add an analog of trange: tenumerate to the standard functions. I can contribute this, the logic is very simple:

def tenumerate(iterable, **kwargs):
    _enumerate = np.ndenumerate if isinstance(iterable, np.ndarray) else enumerate
    return _enumerate(tqdm(iterable, **kwargs))
  • I have marked all applicable categories:
    • exception-raising bug
    • visual output bug
    • 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)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions