Skip to content

fix: ArrayBuilder.show() formatter forwarding#3796

Merged
ianna merged 4 commits intoscikit-hep:mainfrom
aashirvad08:fix-arraybuilder-show-formatter
Jan 12, 2026
Merged

fix: ArrayBuilder.show() formatter forwarding#3796
ianna merged 4 commits intoscikit-hep:mainfrom
aashirvad08:fix-arraybuilder-show-formatter

Conversation

@aashirvad08
Copy link
Copy Markdown
Contributor

ArrayBuilder.show is documented to forward arguments unchanged to
snapshot().show, but currently wraps the formatter argument in a
Formatter instance. This causes Array.show to receive a non-mapping
formatter and raises a TypeError.

This change forwards formatter unchanged and adds a regression test
ensuring ArrayBuilder.show behaves identically to snapshot().show.

Fixes #3724

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.66%. Comparing base (c6fc079) to head (d3ff997).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
Files with missing lines Coverage Δ
src/awkward/highlevel.py 78.52% <100.00%> (+0.22%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Copy Markdown

The documentation preview is ready to be viewed at http://preview.awkward-array.org.s3-website.us-east-1.amazonaws.com/PR3796

@ikrommyd ikrommyd changed the title Fix ArrayBuilder.show formatter forwarding fix: incorrect ArrayBuilder.show() formatter forwarding Jan 11, 2026
Copy link
Copy Markdown
Collaborator

@ikrommyd ikrommyd left a comment

Choose a reason for hiding this comment

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

Thanks @X0708a for this!

This looks like the right fix and it is apparently something that was just forgotten in #3348

Could you also introduce the other arguments that #3348 introduced to show()? See the changes that this PR made and what Array.show() accepts:

def show(
self,
limit_rows=20,
limit_cols=80,
*,
type=False,
named_axis=False,
nbytes=False,
backend=False,
all=False,
stream=STDOUT,
formatter=None,
precision=3,
):

Since snapshot() returns an ak.Array, you can forward all of them to the .snapshot().show(...) call.

I have one comment regarding moving the test in the tests directory and I would also like you to add a bit more testing in the test. Test at least for example the few builder structures that we have in its docstring: https://awkward-array.org/doc/main/reference/generated/ak.ArrayBuilder.html. If you search for ".show()" in your browser in this page, you will see that we do .show() for a few builder types. Just test those in your test.

@aashirvad08 aashirvad08 force-pushed the fix-arraybuilder-show-formatter branch from e0d488b to 8cb253c Compare January 11, 2026 16:10
@aashirvad08
Copy link
Copy Markdown
Contributor Author

Thanks for the review!
I’ve updated ArrayBuilder.show() to forward all arguments supported by Array.show(), moved the test to the appropriate tests directory, and expanded coverage to include multiple builder structures based on the documentation examples.
Please let me know if anything else should be adjusted.

@ikrommyd
Copy link
Copy Markdown
Collaborator

ikrommyd commented Jan 11, 2026

Hi @X0708a, thanks for the changes! I would like to ask you to do a few more things:

  1. You'd still need to remove test_arraybuilder_show_forwards_formatter from src/awkward/highlevel.py.
  2. Could you please update the docstring of the show() method you edited like the others? You added new arguments that need to be reflected in the docstring.
  3. I would urge you to create a new test file instead of editing an old one, so please move your tests from tests/test_2055_array_builder_check.py to a new file that is numbered as 3796 (this PR) or 3724 (the issue it fixes) (tests/test_3796_array_builder_show.py or something like that).
  4. And finally, I made a mistake when I set you can do assert builder.show() == builder.snapshot().show() as show() does not return anything. You are just comparing None == None in this case. Please see tests/test_2803_string_formatter.py to see how to capture those strings in a stream and actually compare them.

I'd recommend git pulling first before pushing instead of force-pushing to grab the changes from the pre-commit ci hook btw.

@aashirvad08 aashirvad08 force-pushed the fix-arraybuilder-show-formatter branch from 6c38511 to 84db75d Compare January 12, 2026 03:41
@aashirvad08
Copy link
Copy Markdown
Contributor Author

Thanks for the detailed feedback.
I’ve removed the test from the source file, updated the ArrayBuilder.show() docstring to reflect the full argument list, moved the tests into a new dedicated test file for this issue, and updated the tests to capture and compare output via a stream as suggested.
Please let me know if anything else should be adjusted.

Copy link
Copy Markdown
Member

@ianna ianna left a comment

Choose a reason for hiding this comment

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

@X0708a - This looks great! Thank you. Just a minor comment - please, move the tests from test_2055*.py to test_3724*.py Thanks!

@aashirvad08 aashirvad08 force-pushed the fix-arraybuilder-show-formatter branch from 49acf67 to 2adee49 Compare January 12, 2026 09:18
@ikrommyd ikrommyd self-requested a review January 12, 2026 11:45
Copy link
Copy Markdown
Collaborator

@ikrommyd ikrommyd left a comment

Choose a reason for hiding this comment

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

Other than the docstring style change that needs to be consistent with the rest and our docs, this looks good to me!

Fix ArrayBuilder.show formatter forwarding
@aashirvad08 aashirvad08 force-pushed the fix-arraybuilder-show-formatter branch from 89df521 to 0bb93d2 Compare January 12, 2026 12:56
@aashirvad08
Copy link
Copy Markdown
Contributor Author

Updated the docstring to match the project’s Args-style documentation and removed the extra blank line under the docstring.
Please let me know if anything else needs adjustment.

@ikrommyd
Copy link
Copy Markdown
Collaborator

ikrommyd commented Jan 12, 2026

I have just pushed a minor docstring change to make it match exactly with the other two show docstrings and merged main on the feature branch. Should be perfect now.

@ikrommyd ikrommyd requested review from ianna and ikrommyd January 12, 2026 13:14
Copy link
Copy Markdown
Collaborator

@ikrommyd ikrommyd left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks!

@ikrommyd
Copy link
Copy Markdown
Collaborator

@all-contributors please add @X0708a for code

@allcontributors
Copy link
Copy Markdown
Contributor

@ikrommyd

I've put up a pull request to add @X0708a! 🎉

@ianna ianna changed the title fix: incorrect ArrayBuilder.show() formatter forwarding fix: ArrayBuilder.show() formatter forwarding Jan 12, 2026
Copy link
Copy Markdown
Member

@ianna ianna left a comment

Choose a reason for hiding this comment

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

@X0708a - Thank you for your contribution! This looks great: all tests pass and the PR is ready to be merged. Thanks!

@ianna ianna enabled auto-merge (squash) January 12, 2026 13:30
@ianna ianna disabled auto-merge January 12, 2026 13:34
@ianna ianna merged commit 6bb426b into scikit-hep:main Jan 12, 2026
40 checks passed
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.

ak.ArrayBuilder.show passes Formatter to ak.Array.show, causing TypeError

3 participants