Skip to content

Commit

Permalink
Added examples for azimuthal and longitudinal properties in 3D and 4D (
Browse files Browse the repository at this point in the history
…#519)

* Added examples for azimuthal and longitudinal properties in 3D and 4D

* Remove comments in examples and update output statements

* Apply suggestions from code review

---------

Co-authored-by: Saransh Chopra <[email protected]>
  • Loading branch information
pandyah5 and Saransh-cpp authored Oct 27, 2024
1 parent 20ac085 commit 2551843
Showing 1 changed file with 72 additions and 8 deletions.
80 changes: 72 additions & 8 deletions src/vector/backends/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1424,14 +1424,46 @@ def __repr__(self) -> str:

@property
def azimuthal(self) -> AzimuthalNumpy:
"""Returns the azimuthal type class for the given ``VectorNumpy3D`` object."""
# TODO: Add an example here - see https://github.com/scikit-hep/vector/issues/194
"""
Returns the azimuthal type class for the given ``VectorNumpy3D`` object.
Example:
>>> import vector
>>> vec = vector.array(
... [
... (1.1, 2.1, 3.1),
... (1.2, 2.2, 3.2),
... (1.3, 2.3, 3.3),
... (1.4, 2.4, 4.4),
... (1.5, 2.5, 5.5)
... ], dtype=[("x", float), ("y", float), ("z", float)]
... )
>>> vec.azimuthal
AzimuthalNumpyXY([(1.1, 2.1), (1.2, 2.2), (1.3, 2.3), (1.4, 2.4),
(1.5, 2.5)], dtype=[('x', '<f8'), ('y', '<f8')])
"""
return self.view(self._azimuthal_type)

@property
def longitudinal(self) -> LongitudinalNumpy:
"""Returns the longitudinal type class for the given ``VectorNumpy3D`` object."""
# TODO: Add an example here - see https://github.com/scikit-hep/vector/issues/194
"""
Returns the longitudinal type class for the given ``VectorNumpy3D`` object.
Example:
>>> import vector
>>> vec = vector.array(
... [
... (1.1, 2.1, 3.1),
... (1.2, 2.2, 3.2),
... (1.3, 2.3, 3.3),
... (1.4, 2.4, 4.4),
... (1.5, 2.5, 5.5)
... ], dtype=[("x", float), ("y", float), ("z", float)]
... )
>>> vec.longitudinal
LongitudinalNumpyZ([(3.1,), (3.2,), (3.3,), (4.4,), (5.5,)],
dtype=[('z', '<f8')])
"""
return self.view(self._longitudinal_type)

def _wrap_result(
Expand Down Expand Up @@ -1704,14 +1736,46 @@ def __repr__(self) -> str:

@property
def azimuthal(self) -> AzimuthalNumpy:
"""Returns the azimuthal type class for the given ``VectorNumpy4D`` object."""
# TODO: Add an example here - see https://github.com/scikit-hep/vector/issues/194
"""
Returns the azimuthal type class for the given ``VectorNumpy4D`` object.
Example:
>>> import vector
>>> vec = vector.array(
... [
... (1.1, 2.1, 3.1, 4.1),
... (1.2, 2.2, 3.2, 4.2),
... (1.3, 2.3, 3.3, 4.3),
... (1.4, 2.4, 3.4, 4.4),
... (1.5, 2.5, 3.5, 4.5)
... ], dtype=[("x", float), ("y", float), ("z", float), ("t", float)]
... )
>>> vec.azimuthal
AzimuthalNumpyXY([(1.1, 2.1), (1.2, 2.2), (1.3, 2.3), (1.4, 2.4),
(1.5, 2.5)], dtype=[('x', '<f8'), ('y', '<f8')])
"""
return self.view(self._azimuthal_type)

@property
def longitudinal(self) -> LongitudinalNumpy:
"""Returns the longitudinal type class for the given ``Vectornumpy4D`` object."""
# TODO: Add an example here - see https://github.com/scikit-hep/vector/issues/194
"""
Returns the longitudinal type class for the given ``VectorNumpy4D`` object.
Example:
>>> import vector
>>> vec = vector.array(
... [
... (1.1, 2.1, 3.1, 4.1),
... (1.2, 2.2, 3.2, 4.2),
... (1.3, 2.3, 3.3, 4.3),
... (1.4, 2.4, 3.4, 4.4),
... (1.5, 2.5, 3.5, 4.5)
... ], dtype=[("x", float), ("y", float), ("z", float), ("t", float)]
... )
>>> vec.longitudinal
LongitudinalNumpyZ([(3.1,), (3.2,), (3.3,), (3.4,), (3.5,)],
dtype=[('z', '<f8')])
"""
return self.view(self._longitudinal_type)

@property
Expand Down

0 comments on commit 2551843

Please sign in to comment.