Skip to content

ENH: delegate broadcast_shapes#713

Merged
lucascolley merged 3 commits into
data-apis:mainfrom
Cyril-36:delegate-broadcast-shapes
May 11, 2026
Merged

ENH: delegate broadcast_shapes#713
lucascolley merged 3 commits into
data-apis:mainfrom
Cyril-36:delegate-broadcast-shapes

Conversation

@Cyril-36
Copy link
Copy Markdown
Contributor

@Cyril-36 Cyril-36 commented May 4, 2026

Part of #100.\n\nSummary:\n- Move the public broadcast_shapes wrapper into the delegation layer.\n- Delegate known integer shapes to numpy.broadcast_shapes when NumPy is available.\n- Preserve the existing fallback for None, math.nan, and no-NumPy runtimes.\n\nTesting:\n- pixi run -e tests pytest -q tests/test_funcs.py::TestBroadcastShapes\n- pixi run -e tests tests\n- pixi run -e lint ruff check src/array_api_extra/_delegation.py src/array_api_extra/_lib/_funcs.py src/array_api_extra/init.py tests/test_funcs.py\n- pixi run -e lint ruff format --check src/array_api_extra/_delegation.py src/array_api_extra/_lib/_funcs.py src/array_api_extra/init.py tests/test_funcs.py\n- pixi run -e lint mypy src/array_api_extra/_delegation.py src/array_api_extra/_lib/_funcs.py tests/test_funcs.py\n- pixi run -e lint pyright src/array_api_extra/_delegation.py src/array_api_extra/_lib/_funcs.py tests/test_funcs.py\n- pixi run -e lint pyrefly check src/array_api_extra/_delegation.py src/array_api_extra/_lib/_funcs.py tests/test_funcs.py\n- pixi run -e docs docs

Copilot AI review requested due to automatic review settings May 4, 2026 07:49

This comment was marked as outdated.

@Cyril-36 Cyril-36 force-pushed the delegate-broadcast-shapes branch from 7dd938d to 5939f4b Compare May 4, 2026 08:02
Comment thread src/array_api_extra/_delegation.py Outdated
@Cyril-36
Copy link
Copy Markdown
Contributor Author

Cyril-36 commented May 4, 2026

Updated based on Copilot review:\n- Added the numpydoc ignore marker to the internal fallback implementation.\n- Moved the optional NumPy import into a helper so NumPy is not imported at module import time.

@Cyril-36 Cyril-36 force-pushed the delegate-broadcast-shapes branch from 5939f4b to 941bbdb Compare May 4, 2026 08:11
@Cyril-36
Copy link
Copy Markdown
Contributor Author

Cyril-36 commented May 4, 2026

Thanks for the review. Updated the implementation to follow the existing delegation pattern: broadcast_shapes now accepts xp, delegates through xp.broadcast_shapes for supported namespaces and known integer shapes, and falls back to the generic implementation for unknown sizes or when no namespace is provided.

Comment thread src/array_api_extra/_delegation.py Outdated
@Cyril-36 Cyril-36 force-pushed the delegate-broadcast-shapes branch from 941bbdb to a0c98d0 Compare May 4, 2026 10:23
@lucascolley lucascolley added enhancement New feature or request delegation labels May 9, 2026
@Cyril-36
Copy link
Copy Markdown
Contributor Author

Hi @lucascolley, just following up. I pushed the requested updates: broadcast_shapes now accepts xp, Dask was removed from the native delegation path, and the previous review comments appear outdated. Please let me know if anything else needs to be changed.

Comment thread src/array_api_extra/_delegation.py
Comment thread tests/test_funcs.py Outdated
@lucascolley lucascolley added this to the 0.10.2 milestone May 11, 2026
@lucascolley lucascolley changed the title ENH: delegate broadcast_shapes ENH: delegate broadcast_shapes May 11, 2026
@Cyril-36
Copy link
Copy Markdown
Contributor Author

Thanks, removed the redundant unknown-size fallback test.

Copy link
Copy Markdown
Member

@lucascolley lucascolley left a comment

Choose a reason for hiding this comment

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

thanks @Cyril-36 !

@lucascolley lucascolley merged commit 32f1413 into data-apis:main May 11, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

delegation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants