Skip to content

Add complex number support to linspace #568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 14, 2022
Merged

Add complex number support to linspace #568

merged 3 commits into from
Dec 14, 2022

Conversation

kgryte
Copy link
Contributor

@kgryte kgryte commented Dec 13, 2022

This PR

  • adds complex number support to linspace.
  • allows start and stop to be complex numbers.
  • allows dtype to a complex floating-point data type, not just a real-valued floating-point data type.
  • specifies that spacing between complex numbers be computed by independently computing the spacing for real and imaginary components, respectively. This follows existing practice in NumPy, PyTorch, Julia, MATLAB, and elsewhere.
  • specifies that if dtype is None, if either start or stop is a complex number, then the output dtype must be the default complex floating-point dtype; otherwise, the output dtype must be the default real-valued floating-point dtype.
  • adds a warning that conversions of start and stop should follow type promotion rules; conversions not following type promotion rules are implementation-dependent (e.g., NumPy allows specifying a real-valued dtype when start and/or stop is complex by discarding the imaginary component; as such a conversion is not specified in this standard, such behavior is implementation-defined).
  • removes a requirement that linspace raise an exception if num is a not a nonnegative integer, as the standard typically avoids specifying validation behavior, leaving it up to conforming libraries to determine how to best handle invalid inputs (e.g., raise an exception, clip inputs, etc).

@kgryte kgryte added API change Changes to existing functions or objects in the API. topic: Complex Data Types Complex number data types. topic: Creation Array creation. labels Dec 13, 2022
@kgryte kgryte added this to the v2022 milestone Dec 13, 2022
Copy link
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

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

This all looks correct, in it goes. Thanks @kgryte

@rgommers rgommers merged commit dff1997 into main Dec 14, 2022
@rgommers rgommers deleted the cmplx-linspace branch December 14, 2022 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API change Changes to existing functions or objects in the API. topic: Complex Data Types Complex number data types. topic: Creation Array creation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants