scikit-hep / scikit-hep/vector
Support for complex numbers
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 99
- Forks
- 42
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 6
Description
Describe the potential feature
Currently the library does not support complex numbers, causing e.g.
import awkward as ak
import vector
arr = ak.Array(
[{"x": 1, "y": 2, "z": 3 + 3j, "t": 5 + 3j}],
with_name="Vector4D",
behavior=vector.backends.awkward.behavior,
)
arr.tau
to fail since np.copysign does not seem to handle complex numbers (see e.g. np.copysign(ak.Array([1, 1j]), ak.Array([1, -1]))).
I ran into this while solving for object kinematics in constrained systems, where the violation of assumptions (e.g. on-shell decay) can result in imaginary contributions to the kinematics. Another example might be math with tachyons. For my use case I can in practice work around this by making all relevant numbers real before hitting any vector codepaths that would otherwise fail.
I am opening this issue to have a place to track the topic and potential interest in vector with complex numbers as I have not seen this discussed previously.
Motivation
No response
Possible Implementation
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the arr.tau failure from the issue and the shown np.copysign example. Then trace the vector paths that use these operations and inspect existing tests for numeric types; done would require an agreed scope for complex-number support and corresponding passing coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100