Skip to content

Support array defaults without ambiguous sentinel comparisons - #647

Open
xiehuanyi wants to merge 1 commit into
pytoolz:masterfrom
xiehuanyi:fix/toolz-array-defaults
Open

xiehuanyi wants to merge 1 commit into
pytoolz:masterfrom
xiehuanyi:fix/toolz-array-defaults

Conversation

@xiehuanyi

Copy link
Copy Markdown

NumPy arrays cannot be used as get/pluck defaults, reduceby initial vectors, or outer join defaults: comparing them directly with the sentinel string produces an array and raises the ambiguous-truth-value error. These are useful defaults when looking up or aggregating vector data.

Restrict the sentinel equality check to strings and UserString values. Keep the existing behavior for the mangled __no__default__ string, including copies, while returning non-string defaults without invoking their equality operator. Add regressions for each affected API and UserString compatibility controls.

This preserves the compatibility behavior discussed in #625. Related #643 addresses accumulate; the changed functions here do not overlap it.

Validation: four NumPy regressions fail on unchanged master; the complete suite passes after the fix (198 tests with NumPy enabled). Pyflakes and line-length checks pass. NumPy is an optional test dependency, not a runtime dependency.

Copilot AI balanced review requested due to automatic review settings October 10, 2026 11:44

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.

This branch has not been deployed

No deployments
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.

2 participants