Skip to content

Fixes common type promotion in array_api concat and stack - #4889

Merged
ajpotts merged 4 commits into
Bears-R-Us:mainfrom
drculhane:Closes-4880
Sep 17, 2025
Merged

ajpotts merged 4 commits into
Bears-R-Us:mainfrom
drculhane:Closes-4880

Conversation

@drculhane

@drculhane drculhane commented Sep 11, 2025 •

Copy link
Copy Markdown
Contributor

Addendum

I neatened this a bit, with a function _has_type, so that the check against all types would be a bit more readable and concise.

Closes #4880

Both concat and stack were using numpy's promote_to_common_dtype to compute the result type. But numpy's concat and stack don't use that. They use the conventional numpy rule of:

any float -> output = float, else
any int AND any uint -> output = float, else
any int -> output = int, else
any uint -> output = uint, else
any bool -> output = bool, else
error

This PR implements the correct type promotion.

Possible point of discussion:

I've done the check (and type conversion) python-side. The "where" function, implemented in EfuncMsg.chpl, does the same check chapel-side. On the one hand, I would prefer to be consistent. On the other hand, that would create multiple instantiations of the chapel-side proc, and we've recently been running up against instantiation limits.

I am entirely open to discussion on whether to move this chapel-side.

@1RyanK 1RyanK left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good!

@jaketrookman jaketrookman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good

@jaketrookman jaketrookman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good

@ajpotts
ajpotts added this pull request to the merge queue Sep 17, 2025
Merged via the queue into Bears-R-Us:main with commit e4260d6 Sep 17, 2025
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.

Fix common type handling in array_api concat and stack

4 participants