Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tqdm_1/tqdm/contrib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def tenumerate(iterable, start=0, total=None, tqdm_class=tqdm_auto,
if isinstance(iterable, np.ndarray):
return tqdm_class(np.ndenumerate(iterable),
total=total or len(iterable), **tqdm_kwargs)
Comment on lines 38 to 40
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Inconsistent start parameter handling in numpy path.

The numpy code path doesn't handle the start parameter at all, creating inconsistent behavior between numpy arrays and other iterables.

        if isinstance(iterable, np.ndarray):
            return tqdm_class(np.ndenumerate(iterable),
-                              total=total or len(iterable), **tqdm_kwargs)
+                              total=total or len(iterable), 
+                              initial=start, **tqdm_kwargs)

This assumes start should affect the initial progress bar position consistently across both code paths.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if isinstance(iterable, np.ndarray):
return tqdm_class(np.ndenumerate(iterable),
total=total or len(iterable), **tqdm_kwargs)
if isinstance(iterable, np.ndarray):
return tqdm_class(np.ndenumerate(iterable),
total=total or len(iterable),
initial=start, **tqdm_kwargs)
🤖 Prompt for AI Agents
In tqdm_1/tqdm/contrib/__init__.py around lines 38 to 40, the numpy array
handling path does not use the `start` parameter, causing inconsistent progress
bar behavior compared to other iterables. Modify the numpy path to pass the
`start` parameter to the tqdm_class constructor, ensuring the initial progress
bar position respects `start` consistently across all iterable types.

return enumerate(tqdm_class(iterable, **tqdm_kwargs), start)
return enumerate(tqdm_class(iterable, start, **tqdm_kwargs))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Breaking change: start parameter behavior fundamentally altered.

This change moves the start parameter from controlling enumeration indexing (via enumerate()) to being passed to tqdm_class, which likely affects progress bar display instead. This is a significant breaking change that will affect existing users who rely on start for enumeration indexing.

Issues identified:

  1. API contract violation: Users expecting tenumerate(items, start=10) to start enumeration at index 10 will get different behavior
  2. Documentation inconsistency: The docstring claims equivalence to builtin enumerate, but this is no longer true for the start parameter
  3. Inconsistent handling: The numpy path (lines 38-40) doesn't handle start at all

Verification needed:

Consider either:

  • Reverting this change to maintain backwards compatibility
  • Updating the docstring to clearly document the new behavior
  • Adding a deprecation warning for the transition period

🏁 Script executed:

#!/bin/bash
# Search for existing usage of tenumerate with start parameter to assess impact
rg -A 3 -B 3 "tenumerate.*start\s*=" 

# Look for any documentation or tests that might explain the intended behavior
rg -A 5 -B 5 "start.*enumerate|enumerate.*start"

Length of output: 1933


Breaking change: start now controls the progress bar, not the enumeration index

The recent change moves the start argument from Python’s built-in enumerate() to the tqdm_class constructor. This diverges from the documented behavior (“equivalent to enumerate”) and will break any code that relies on tenumerate(..., start=N) to begin counting at N.

Locations requiring attention:

  • tqdm_1/tqdm/contrib/init.py:41
  • return enumerate(tqdm_class(iterable, **tqdm_kwargs), start)
  • return enumerate(tqdm_class(iterable, start, **tqdm_kwargs))
- **Docstring for `tenumerate`** still claims equivalence to the builtin `enumerate`, but the `start` parameter now affects only the progress‐bar offset, not the index returned.
- **NumPy branch (lines 38–40)**:  
```python
if isinstance(iterable, np.ndarray):
    return tqdm_class(np.ndenumerate(iterable),
                      total=total or len(iterable), **tqdm_kwargs)

ignores start entirely.

Recommended fixes:

  • Restore the original enumeration behavior by passing start to enumerate() (and remove it from tqdm_class), or
  • If the new behavior is intentional:
    • Update the docstring to clearly state that start now only offsets the progress bar.
    • Implement start support in the NumPy path (e.g., wrap the iterator in enumerate(..., start)).
    • Add a deprecation warning for the old enumeration behavior and bump the major version to signal the breaking change.
🤖 Prompt for AI Agents
In tqdm_1/tqdm/contrib/__init__.py at line 41, the start parameter is
incorrectly passed to tqdm_class instead of enumerate, breaking the expected
enumeration indexing behavior. To fix this, revert the change by passing start
to the built-in enumerate() function to control the enumeration index, and
remove start from tqdm_class arguments. Additionally, update the NumPy branch
(lines 38-40) to wrap the iterator with enumerate(..., start) to maintain
consistent start behavior. Finally, update the tenumerate docstring to reflect
the correct behavior of start controlling enumeration indexing, or if the new
behavior is intended, clearly document the change, add a deprecation warning,
and handle start consistently in all code paths.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 Warning 🐛 Bug

tenumerate's start parameter is ignored, causing the index to always start at 0.

Issue Explanation
  • In blarApp/open-benchmark/tqdm_1/tqdm/contrib/init.py, the code calls:
    return enumerate(tqdm_class(iterable, start, **tqdm_kwargs))
  • The start argument is passed to tqdm_class instead of to enumerate.
  • As a result, enumerate uses its default start=0 and ignores the start passed to tenumerate.
  • The start parameter on tenumerate has no effect on the returned indices.
  • Fix: pass start to enumerate, for example:
    return enumerate(tqdm_class(iterable, **tqdm_kwargs), start=start)

Reply if you have any questions or let me know if I missed something.
Don't forget to react with a 👍 or 👎 to the comments made by Blar to help us improve.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 Warning 🐛 Bug

Passing the start value positionally to tqdm_class sets it as desc instead of the initial counter.

Issue Explanation
  • In blarApp/open-benchmark/tqdm_1/tqdm/contrib/init.py:tenumerate, the call uses tqdm_class(iterable, start, **tqdm_kwargs).
  • tqdm signature is tqdm(iterable=None, desc=None, total=None, initial=0, ...), so the second positional argument maps to desc.
  • The bar’s description receives the start value, leaving initial at its default (0).
  • Enumerated indices start at zero regardless of the start parameter.
  • Solution: pass start as a named argument, e.g. tqdm_class(iterable, initial=start, **tqdm_kwargs).
return enumerate(tqdm_class(iterable, start, **tqdm_kwargs))

Reply if you have any questions or let me know if I missed something.
Don't forget to react with a 👍 or 👎 to the comments made by Blar to help us improve.



def _tzip(iter1, *iter2plus, **tqdm_kwargs):
Expand Down
1 change: 0 additions & 1 deletion tqdm_1/tqdm/tests/tests_contrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def test_enumerate():
with closing(StringIO()) as our_file:
a = range(9)
assert list(tenumerate(a, file=our_file)) == list(enumerate(a))
assert list(tenumerate(a, 42, file=our_file)) == list(enumerate(a, 42))


@with_setup(pretest, posttest)
Expand Down