Skip to content

Add complex number support to asarray - #434

Merged
kgryte merged 2 commits into
mainfrom
cmplx-asarray
Jun 6, 2022
Merged

Add complex number support to asarray#434
kgryte merged 2 commits into
mainfrom
cmplx-asarray

Conversation

@kgryte

Copy link
Copy Markdown
Contributor

This PR

  • adds complex number support to asarray. Importantly, if one or more values are complex numbers, the output data type must be the default complex floating-point data type.

@kgrytekgryte added API change Changes to existing functions or objects in the API. topic: Complex Data Types Complex number data types. labels May 23, 2022
@kgrytekgryte added this to the v2022 milestone May 23, 2022

@rgommersrgommers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM modulo a few small textual things.

Comment threadspec/API_specification/array_api/creation_functions.py
Comment threadspec/API_specification/array_api/creation_functions.py Outdated
@leofang

Copy link
Copy Markdown
Contributor

I fail to see why complex should appear before (or after) float with the "precedence" clause, I must be missing something...

@kgryte

kgryte commented May 25, 2022

Copy link
Copy Markdown
ContributorAuthor

@leofang Because if at least one value is complex, then the returned array must have a complex data type. Hence, if provided a mixture of complex and float, complex takes precedence. This is similar to type promotion semantics.

@kgryte

Copy link
Copy Markdown
ContributorAuthor

Thanks, @leofang! As this now has two approvals, will merge and any further changes can be addressed through subsequent PRs...

@kgryte
kgryte merged commit b09cda6 into mainJun 6, 2022
@kgryte
kgryte deleted the cmplx-asarray branch June 6, 2022 20:11
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API changeChanges to existing functions or objects in the API.topic: Complex Data TypesComplex number data types.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@kgryte@leofang@asmeurer@rgommers