From 6a954080cbc617155cfbc4f7a695ee520030e745 Mon Sep 17 00:00:00 2001 From: Aditi Juneja <1509aditi@gmail.com> Date: Mon, 27 Apr 2026 22:11:24 +0530 Subject: [PATCH] added empty slots to _methods.py and backends/object.py --- src/vector/_methods.py | 51 +++++++++++++++++++++++++++++++++-- src/vector/backends/object.py | 23 ++++++++++++++++ 2 files changed, 72 insertions(+), 2 deletions(-) diff --git a/src/vector/_methods.py b/src/vector/_methods.py index 9a668e3f..81ccb016 100644 --- a/src/vector/_methods.py +++ b/src/vector/_methods.py @@ -22,10 +22,12 @@ class Coordinates: - pass + __slots__ = () class Azimuthal(Coordinates): + __slots__ = () + @property def elements(self) -> tuple[ScalarCollection, ScalarCollection]: """ @@ -38,6 +40,8 @@ def elements(self) -> tuple[ScalarCollection, ScalarCollection]: class Longitudinal(Coordinates): + __slots__ = () + @property def elements(self) -> tuple[ScalarCollection]: """ @@ -50,6 +54,8 @@ def elements(self) -> tuple[ScalarCollection]: class Temporal(Coordinates): + __slots__ = () + @property def elements(self) -> tuple[ScalarCollection]: """ @@ -68,6 +74,7 @@ class AzimuthalXY(Azimuthal): y (scalar, ``np.ndarray``, ``ak.Array``, etc.): The $y$ coordinate(s). """ + __slots__ = () x: ScalarCollection y: ScalarCollection @@ -79,6 +86,7 @@ class AzimuthalRhoPhi(Azimuthal): phi (scalar, ``np.ndarray``, ``ak.Array``, etc.): The $\phi$ coordinate(s). """ + __slots__ = () rho: ScalarCollection phi: ScalarCollection @@ -89,6 +97,7 @@ class LongitudinalZ(Longitudinal): z (scalar, ``np.ndarray``, ``ak.Array``, etc.): The $z$ coordinate(s). """ + __slots__ = () z: ScalarCollection @@ -98,6 +107,7 @@ class LongitudinalTheta(Longitudinal): theta (scalar, ``np.ndarray``, ``ak.Array``, etc.): The $\theta$ coordinate(s). """ + __slots__ = () theta: ScalarCollection @@ -107,6 +117,7 @@ class LongitudinalEta(Longitudinal): eta (scalar, ``np.ndarray``, ``ak.Array``, etc.): The $\eta$ coordinate(s). """ + __slots__ = () eta: ScalarCollection @@ -116,6 +127,7 @@ class TemporalT(Temporal): t (scalar, ``np.ndarray``, ``ak.Array``, etc.): The $t$ coordinate(s). """ + __slots__ = () t: ScalarCollection @@ -125,6 +137,7 @@ class TemporalTau(Temporal): tau (scalar, ``np.ndarray``, ``ak.Array``, etc.): The $\tau$ coordinate(s). """ + __slots__ = () tau: ScalarCollection @@ -148,6 +161,8 @@ class VectorProtocol: momentum-synonyms. """ + __slots__ = () + @property def lib(self) -> Module: ... @@ -710,6 +725,8 @@ def like(self, other: VectorProtocol) -> VectorProtocol: class VectorProtocolPlanar(VectorProtocol): + __slots__ = () + @property def azimuthal(self) -> Azimuthal: """ @@ -833,6 +850,8 @@ def is_perpendicular( class VectorProtocolSpatial(VectorProtocolPlanar): + __slots__ = () + @property def longitudinal(self) -> Longitudinal: """ @@ -1087,6 +1106,8 @@ def is_perpendicular( class VectorProtocolLorentz(VectorProtocolSpatial): + __slots__ = () + @property def temporal(self) -> Temporal: """ @@ -1458,6 +1479,8 @@ def is_lightlike(self, tolerance: ScalarCollection = 1e-5) -> BoolCollection: class MomentumProtocolPlanar(VectorProtocolPlanar): + __slots__ = () + @property def px(self) -> ScalarCollection: """Momentum-synonym for :attr:`vector._methods.VectorProtocolPlanar.x`.""" @@ -1480,6 +1503,8 @@ def pt2(self) -> ScalarCollection: class MomentumProtocolSpatial(VectorProtocolSpatial, MomentumProtocolPlanar): + __slots__ = () + @property def pz(self) -> ScalarCollection: """Momentum-synonym for :attr:`vector._methods.VectorProtocolSpatial.z`.""" @@ -1502,6 +1527,8 @@ def p2(self) -> ScalarCollection: class MomentumProtocolLorentz(VectorProtocolLorentz, MomentumProtocolSpatial): + __slots__ = () + @property def E(self) -> ScalarCollection: """Momentum-synonyor :attr:`vector._methods.VectorProtocolLorentz.t`.""" @@ -1648,6 +1675,8 @@ def transverse_mass2(self) -> ScalarCollection: class Vector(VectorProtocol): + __slots__ = () + @typing.overload def __new__(cls, *, x: float, y: float) -> vector.VectorObject2D: ... @@ -3170,6 +3199,8 @@ def like(self, other: VectorProtocol) -> VectorProtocol: class Vector2D(Vector, VectorProtocolPlanar): + __slots__ = () + def to_Vector2D(self) -> VectorProtocolPlanar: return self @@ -3306,6 +3337,8 @@ def to_4D(self, **kwargs: float | None) -> VectorProtocolLorentz: class Vector3D(Vector, VectorProtocolSpatial): + __slots__ = () + def to_Vector2D(self) -> VectorProtocolPlanar: return self._wrap_result( type(self), @@ -3384,6 +3417,8 @@ def to_4D(self, **kwargs: float | None) -> VectorProtocolLorentz: class Vector4D(Vector, VectorProtocolLorentz): + __slots__ = () + def to_Vector2D(self) -> VectorProtocolPlanar: return self._wrap_result( type(self), @@ -3423,6 +3458,8 @@ def to_4D(self) -> VectorProtocolLorentz: class Planar(VectorProtocolPlanar): + __slots__ = () + @property def x(self) -> ScalarCollection: from vector._compute.planar import x @@ -3554,6 +3591,8 @@ def isclose( class Spatial(Planar, VectorProtocolSpatial): + __slots__ = () + @property def z(self) -> ScalarCollection: from vector._compute.spatial import z @@ -3794,6 +3833,8 @@ def isclose( class Lorentz(Spatial, VectorProtocolLorentz): + __slots__ = () + @property def t(self) -> ScalarCollection: from vector._compute.lorentz import t @@ -4065,10 +4106,12 @@ def isclose( class Momentum: - pass + __slots__ = () class PlanarMomentum(Momentum, MomentumProtocolPlanar): + __slots__ = () + @property def px(self) -> ScalarCollection: return self.x @@ -4087,6 +4130,8 @@ def pt2(self) -> ScalarCollection: class SpatialMomentum(PlanarMomentum, MomentumProtocolSpatial): + __slots__ = () + @property def pz(self) -> ScalarCollection: return self.z @@ -4105,6 +4150,8 @@ def p2(self) -> ScalarCollection: class LorentzMomentum(SpatialMomentum, MomentumProtocolLorentz): + __slots__ = () + @property def E(self) -> ScalarCollection: return self.t diff --git a/src/vector/backends/object.py b/src/vector/backends/object.py index ac9ad986..d457cac3 100644 --- a/src/vector/backends/object.py +++ b/src/vector/backends/object.py @@ -71,18 +71,26 @@ class CoordinatesObject: """Coordinates class for the Object backend.""" + __slots__ = () + class AzimuthalObject(CoordinatesObject, Azimuthal): """Azimuthal class for the Object backend.""" + __slots__ = () + class LongitudinalObject(CoordinatesObject, Longitudinal): """Longitudinal class for the Object backend.""" + __slots__ = () + class TemporalObject(CoordinatesObject, Temporal): """Temporal class for the Object backend.""" + __slots__ = () + class TupleXY(typing.NamedTuple): """``x`` and ``y`` coordinates as a ``NamedTuple``.""" @@ -97,6 +105,8 @@ class AzimuthalObjectXY(AzimuthalObject, AzimuthalXY, TupleXY): Use the ``elements`` property to retrieve the coordinates. """ + __slots__ = () + @property def elements(self) -> tuple[float, float]: """ @@ -126,6 +136,8 @@ class AzimuthalObjectRhoPhi(AzimuthalObject, AzimuthalRhoPhi, TupleRhoPhi): Use the ``elements`` property to retrieve the coordinates. """ + __slots__ = () + @property def elements(self) -> tuple[float, float]: """ @@ -154,6 +166,8 @@ class LongitudinalObjectZ(LongitudinalObject, LongitudinalZ, TupleZ): Use the ``elements`` property to retrieve the coordinates. """ + __slots__ = () + @property def elements(self) -> tuple[float]: """ @@ -182,6 +196,8 @@ class LongitudinalObjectTheta(LongitudinalObject, LongitudinalTheta, TupleTheta) Use the ``elements`` property to retrieve the coordinates. """ + __slots__ = () + @property def elements(self) -> tuple[float]: """ @@ -210,6 +226,8 @@ class LongitudinalObjectEta(LongitudinalObject, LongitudinalEta, TupleEta): Use the ``elements`` property to retrieve the coordinates. """ + __slots__ = () + @property def elements(self) -> tuple[float]: """ @@ -238,6 +256,8 @@ class TemporalObjectT(TemporalObject, TemporalT, TupleT): Use the ``elements`` property to retrieve the coordinates. """ + __slots__ = () + @property def elements(self) -> tuple[float]: """ @@ -266,6 +286,8 @@ class TemporalObjectTau(TemporalObject, TemporalTau, TupleTau): Use the ``elements`` property to retrieve the coordinates. """ + __slots__ = () + @property def elements(self) -> tuple[float]: """ @@ -329,6 +351,7 @@ def _replace_data(obj: typing.Any, result: typing.Any) -> typing.Any: class VectorObject(Vector): # noqa: PLW1641 """Mixin class for Object vectors.""" + __slots__ = () lib = numpy # The type ignore comments below cannot be removed because `VectorObject`