Skip to content
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

Add conj specification for computing the complex conjugate #446

Merged
merged 5 commits into from
Oct 10, 2022
Merged

Conversation

kgryte
Copy link
Contributor

@kgryte kgryte commented May 30, 2022

This PR

Notes

  • Re: restricting to complex dtypes. We should note that this, similar to real, runs contrary to array libraries, more generally, which allow real-valued arrays as input and define conj as a no-op for those inputs (see PyTorch v1.11, TensorFlow, and NumPy). However, this PR chooses to be consistent with real in requiring users to provide a complex number array for the primary reason that, in most cases, when a user is calling conj(z), the expectation is that z is complex-valued, and, if real-valued, this is likely a bug.

@kgryte kgryte added API extension Adds new functions or objects to the API. topic: Complex Data Types Complex number data types. labels May 30, 2022
@kgryte kgryte added this to the v2022 milestone May 30, 2022
@leofang
Copy link
Contributor

leofang commented Sep 6, 2022

Would be nice if we can discuss #425 again this week. It seems this and #427 are blocked.

@seberg
Copy link
Contributor

seberg commented Sep 22, 2022

My feeling would be that we should probably allow it, since Python itself also always implemntes .real and .conjugate() (althought not .imag I believe).
But of course for now that just means not explicitly saying that it must be forbidden (vs. should not be allowed or does not have to be allowed).

@kgryte
Copy link
Contributor Author

kgryte commented Oct 10, 2022

As discussed in the Sept 22, 2022, consortium meeting, the plan is to merge this PR as is. We can revisit the decision to only support complex dtypes based on downstream library implementations and feedback should this prove problematic/undesirable.

The spec, as written, uses should, so implementors can extend to real-valued dtypes for reasons of backward compatibility. However, users should only except that complex dtypes will work across all spec compliant array API implementations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API extension Adds new functions or objects to the API. topic: Complex Data Types Complex number data types.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants