scikit-hep / scikit-hep/vector

Support for complex numbers

Open
#625 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.