Give put_along_axis axis a default of None like take_along_axis - #4360
Open
ayaangazali wants to merge 1 commit into
Open
Give put_along_axis axis a default of None like take_along_axis#4360ayaangazali wants to merge 1 commit into
ayaangazali wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is wrong
mx.put_along_axisdocumentsaxisas optional with a default ofNone, and its implementation already handles theNonecase (flatten to 1D then index), but the binding marksaxisas required. Calling it withoutaxisraises, and the error message prints the very signature it just rejected:The
nb::sigstring and the docstring both sayaxis: int | None = None, so the reference and the actual binding disagree.Why
The parameter is declared
"axis"_a.none(), which permitsNoneto be passed but sets no default value, so the argument stays required. This is the same defect that #4357 just fixed for the siblingtake_along_axis;put_along_axishas the identical signature and the identicalaxis.has_value()flatten path, and was missed.What this changes
One line, mirroring #4357:
After it, the flattened form works and matches the documented signature:
No test added, matching #4357 which shipped the same one-line fix for
take_along_axiswithout one. Full CPU rebuild, clang-format clean, and the compiled binding verified by the calls above.I am new and lean on Claude Code, so I kept this to the exact shape of the merged sibling fix and checked the rebuilt binding by hand rather than trusting the source. Point me at anything you want done differently.