-
Notifications
You must be signed in to change notification settings - Fork 31
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
Record type is not correct for downcasting awkward vectors #412
Comments
One significant consequence is that checking equality
|
Thanks for reporting this! This definitely is a bug, but we should decide what behavior we consider a bug. For instance, the other 2 backends preserve the In [1] import vector
In [2]: vector.obj(x=1, y=2, z=3, t=4) + vector.obj(x=1, y=2, z=3)
Out[2]: VectorObject4D(x=2, y=4, z=6, t=4)
In [3]: vector.obj(x=1, y=2, z=3, t=4) - vector.obj(x=1, y=2, z=3)
Out[3]: VectorObject4D(x=0, y=0, z=0, t=4)
In [4]: - vector.obj(x=1, y=2, z=3, t=4) + vector.obj(x=1, y=2, z=3)
Out[4]: VectorObject4D(x=0, y=0, z=0, t=-4)
In [5]: v = vector.VectorNumpy4D(
...: {
...: "x": [1.1, 1.2, 1.3, 1.4, 1.5],
...: "y": [2.1, 2.2, 2.3, 2.4, 2.5],
...: "z": [3.1, 3.2, 3.3, 3.4, 3.5],
...: "t": [4.1, 4.2, 4.3, 4.4, 4.5],
...: }
...: )
In [6]: v2 = vector.VectorNumpy3D(
...: {
...: "x": [1.1, 1.2, 1.3, 1.4, 1.5],
...: "y": [2.1, 2.2, 2.3, 2.4, 2.5],
...: "z": [3.1, 3.2, 3.3, 3.4, 3.5],
...: }
...: )
In [7]: v - v2
Out[7]:
VectorNumpy4D([(0., 0., 0., 4.1), (0., 0., 0., 4.2), (0., 0., 0., 4.3),
(0., 0., 0., 4.4), (0., 0., 0., 4.5)],
dtype=[('x', '<f8'), ('y', '<f8'), ('z', '<f8'), ('t', '<f8')])
In [8]: v2 -v
Out[8]:
VectorNumpy3D([(0., 0., 0.), (0., 0., 0.), (0., 0., 0.), (0., 0., 0.),
(0., 0., 0.)], dtype=[('x', '<f8'), ('y', '<f8'), ('z', '<f8')])
In [9]: v - v2
Out[9]:
VectorNumpy4D([(0., 0., 0., 4.1), (0., 0., 0., 4.2), (0., 0., 0., 4.3),
(0., 0., 0., 4.4), (0., 0., 0., 4.5)],
dtype=[('x', '<f8'), ('y', '<f8'), ('z', '<f8'), ('t', '<f8')])
In [10]: - v + v2
Out[10]:
VectorNumpy4D([(0., 0., 0., -4.1), (0., 0., 0., -4.2), (0., 0., 0., -4.3),
(0., 0., 0., -4.4), (0., 0., 0., -4.5)],
dtype=[('x', '<f8'), ('y', '<f8'), ('z', '<f8'), ('t', '<f8')]) I think the bug here is that the Tagging @jpivarski here for further discussion. |
It's more than that, the other backends also have the same infix operator issue:
you get a different type depending on which is first. |
My preference is to not have |
I also think that it should drop Namely, if an operation takes more than one vector as input and would return a vector of the same type as output (e.g. |
Vector Version
1.1.1.post1
Python Version
3.10.12
OS / Environment
OS/x
Describe the bug
returns
So, although the fields available are the ones expected, the record type is incorrect in the first case. Similar issues are present for
a+c
andb+c
.Any additional but relevant log output
No response
The text was updated successfully, but these errors were encountered: