Skip to content

Support integer in-place multiplication and preserve empty cycle keys - #110

Closed
nawaaaaaAaar wants to merge 2 commits into
matplotlib:mainfrom
nawaaaaaAaar:fix/inplace-integer-multiplication
Closed

nawaaaaaAaar wants to merge 2 commits into
matplotlib:mainfrom
nawaaaaaAaar:fix/inplace-integer-multiplication

Conversation

@nawaaaaaAaar

@nawaaaaaAaar nawaaaaaAaar commented Oct 22, 2026 •

Copy link
Copy Markdown

Summary

Restore the documented integer form of in-place multiplication (styles *= n) while preserving the existing Cycler-product behavior.

Ordinary integer multiplication works for positive counts, but the in-place form raises TypeError. Testing zero/negative counts exposed a prerequisite: composing/copying empty cycles loses their declared keys or raises StopIteration. Preserve key metadata independently of the first generated row and reuse ordinary multiplication for the in-place operation, retaining object identity.

Before/after

Unchanged upstream: d1737eb0a42bd451e8770cef245ebe60ebb36bfc.

from cycler import cycler
styles = cycler(color=["red", "blue"])
styles *= 2  # Before: TypeError; after: repeated styles, same object

The final regression selection yields 19 failures and two passes before the implementation change, then 21 passes afterward. Coverage includes base/summed/product cycles, integer counts -2/0/1/2/3, object identity, equality, key metadata, representation and by-key values.

Verification

  • Full suite: 49 passed on Python 3.9.25 with two xdist workers and Python 3.12.13; no skips.
  • Both runs report 99% combined statement/branch coverage.
  • Source distribution and wheel build with python -m build --no-isolation.
  • git diff --check passes.
  • Full flake8 and project-pinned mypy 1.5.1 checks pass. Final workflow inspection caught the separate reviewdog lint/type workflow; a narrow helper correction preserves the existing annotated iterable input contract as well as Cycler metadata.
  • Linux-only local checks; Python 3.8 and other supported versions/platforms were not all tested. Hosted results remain separate.

Assistance

Prepared using AI assistance for investigation, implementation and tests. No personal account-owner review, provenance attestation or maintainer acceptance is asserted. This is one coherent multiplication correctness change, including the empty-result prerequisite, not separate PRs for the same operation.
Fixes #109.

Copilot AI balanced review requested due to automatic review settings October 22, 2026 12:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@timhoffm

Copy link
Copy Markdown
Member

This violates our AI policy.

@timhoffm timhoffm closed this Oct 22, 2026
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

Successfully merging this pull request may close these issues.

Documented integer in-place multiplication raises TypeError; empty composed repetitions lose keys

3 participants