Skip to content

Add mincolwidths parameter to tabulate() - #2

Open
dudududi144-source wants to merge 1 commit into
masterfrom
devgate/task-brre1mgk
Open

dudududi144-source wants to merge 1 commit into
masterfrom
devgate/task-brre1mgk

Conversation

@dudududi144-source

Copy link
Copy Markdown
Owner

Adds a new optional keyword argument mincolwidths to tabulate() that enforces minimum display widths for columns. Accepts either:

  • a single integer applied to every column, or
  • a list with one entry per column.

Implementation

  • Inserted mincolwidths=None as a new optional keyword in the tabulate() signature (placed next to maxheadercolwidths for logical grouping).
  • After minwidths is finalized for the columns, applied a per-column max(mw, mcw) so user-supplied minima widen columns that would otherwise be narrower.
  • A single integer is broadcast to all columns; shorter lists are padded with None (treated as 0) to match the number of columns.
  • Documented the new parameter in the tabulate() docstring.

Tests

  • All 382 pre-existing tests pass (1 unrelated skip).
  • The signature regression test (test_tabulate_signature) is updated to include ("mincolwidths", None) so it still passes after the addition of the new optional parameter.

Verification

All DoD commands (R1-R6) pass:

  • R1: tabulate([[1,2,3],[4,5,6]], mincolwidths=[5,5,5]) no longer raises TypeError.
  • R2: mincolwidths=6 produces header separator segments of length ≥ 6.
  • R3: mincolwidths=[3,5,2] enforces per-column minimum widths.
  • R4: mincolwidths=2 combined with maxcolwidths=4 works correctly.
  • R5: python3 -m pytest -q -> 382 passed, 1 skipped.
  • R6: tabulate([[1,2],[3,4]]) and tabulate([[1,2],[3,4]], mincolwidths=None) produce identical output.

No existing parameters, behaviour, or tests are broken.

Adds a new optional keyword argument `mincolwidths` to `tabulate()` that
enforces minimum display widths for columns. Accepts either a single
integer (applied to all columns) or a list with one entry per column.

Implementation pads each column's minimum width with the user-supplied
minimum (per-column when a list, broadcast to all columns when an int),
keeping all existing behaviour, parameters, and tests intact. Also
extends the signature regression test to reflect the new optional
parameter.
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.

1 participant