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

Arithmetic broken for G3 numeric types #83

Closed
ndhuang opened this issue Aug 23, 2022 · 1 comment · Fixed by #84
Closed

Arithmetic broken for G3 numeric types #83

ndhuang opened this issue Aug 23, 2022 · 1 comment · Fixed by #84
Assignees

Comments

@ndhuang
Copy link
Collaborator

ndhuang commented Aug 23, 2022

G3 numeric types (and their vector equivalents) all seem to have some broken arithmetic operations, either with numpy and python scalars, or even with themselves. Here is a sampling of things that raise TypeError: unsupported operand...:

G3Int + G3Int
int + G3Int
G3Int + int
G3VectorInt + int
G3VectorDouble + G3VectorDouble
float * G3VectorDouble
float + G3VectorDouble
G3VectorDouble + float
G3VectorComplexDouble * float

Notably, the follwing do work:

np.float64 * G3VectorDouble
G3VectorDouble * np.float64
G3VectorDouble * float
G3VectorComplexDouble * float64
@arahlin
Copy link
Member

arahlin commented Aug 24, 2022

I suspect this is not easy to resolve. You can work around the issue by using np.asarray() on G3VectorInt and G3VectorDouble objects for now, since the result is a view on the underlying shared memory buffer.

arahlin added a commit that referenced this issue Sep 16, 2022
* Implement binary and unary ufuncs for G3Timestream, G3VectorComplexDouble, ComplexDoubleVector, G3VectorDouble, DoubleVector, G3VectorInt, IntVector, G3VectorBool, BoolVector to enable arithmetic operations involving these types or scalars or numpy arrays on either side of each operator.
* Implement bindings for G3TimestreamMap that mimic the behavior of SO's G3SuperTimestream objects (.times, .data, .names properties).  Note that this also changes the existing `G3TimestreamMap.times()` method into a property attribute.

Fixes #83 (as much as possible)

Co-authored-by: Nicholas Huang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants