harbor run -t openthoughts/tasktrove-swe-rebench-patched-oracle-swe_rebench-05132harbor download openthoughts/tasktrove-swe-rebench-patched-oracle-swe_rebench-05132cd /testbed
git clone https://github.com/scikit-hep/vector.git . && git checkout 17af58fb958145da2b2c2e3acf1192b633575ad1
apt-get update
apt-get install -y gcc
pip install -r /setup_files/requirements.txt
pip install -e .[dev]
pip install pytest pytest-asyncio
Allow users to pass new coordinate values in to_Vector{X}D and to_{new coordinate names}
Right now users can convert a 2D vector to 3D or 4D using to_Vector3D() and to_Vector4D(), but the returned vector always possesses 0 as the value of the new generated coordinate.
Example:
In [1]: import vector
In [2]: v = vector.obj(x=1, y=2)
In [3]: v.to_Vector3D()
Out[3]: VectorObject3D(x=1, y=2, z=0)
In [4]: v.to_Vector3D(z=1)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In [4], line 1
----> 1 v.to_Vector3D(z=1)
TypeError: to_Vector3D() got an unexpected keyword argument 'z'
This can be extended such that the users can pass in the value of the newly added coordinate.
Example:
In [1]: import vector
In [2]: v = vector.obj(x=1, y=2)
In [3]: v
Out[3]: VectorObject2D(x=1, y=2)
In [4]: v.to_Vector3D(z=1)
Out[4]: VectorObject3D(x=1, y=2, z=1)
Similarly for 3D and 4D vectors. This can then be further propagated to the to_{new coordinate name} (to_xyzt, to_rhophi, ...) methods.
The discussion on gitter (between @jpivarski and @henryiii). Quoting a part here -
For 3D and 4D vectors, you probably want a specialized function, since that 4th dimension is qualitatively different from the other 3. Maybe something like scale_spatial(-1). (There's already a scale; it does the same thing as multiplication by a scalar.)
But even without that, it would also be nice if functions like to_Vector4D, which is increasing the dimensionality of the 3D vector (x.to_Vector3D()) in this case, could take parameters like E= or mass= to assign a value to the new dimension. As it is, to_Vector4D applied to a 3D vector creates a 4th dimension whose value is 0 in Cartesian coordinates. To get the original x.E in it, I had to add vectors. If the coordinate were expressed as a mass, the above trick wouldn't work with x.mass because it would add after assigning a mass; non-Cartesian coordinates don't commute.
Changing this -
to this -
def to_Vector3D(self, **coord) -> VectorProtocolSpatial:
if len(coord) > 1:
raise ArgumentError(coord, "can be `z`, `theta`, or `eta`")
coord_type, coord_value = list(coord.keys())[0], list(coord.values())[0]
if coord_type == "z":
l_type = LongitudinalZ
elif coord_type == "eta":
l_type = LongitudinalEta
elif coord_type == "theta":
l_type = LongitudinalTheta
return self._wrap_result(
type(self),
self.azimuthal.elements + (coord_value,),
[_aztype(self), l_type, None],
1,
)
works -
In [1]: import vector
In [2]: v = vector.obj(x=1, py=2)
In [3]: v.to_Vector3D(z=3)
Out[3]: vector.MomentumObject3D(px=1, py=2, pz=3)
In [4]: v.to_Vector3D(eta=3)
Out[4]: vector.MomentumObject3D(px=1, py=2, eta=3)
In [5]: v.to_Vector3D(theta=3)
Out[5]: vector.MomentumObject3D(px=1, py=2, theta=3)