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

Added examples for azimuthal and longitudinal properties in 3D and 4D #519

Merged
merged 3 commits into from
Oct 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
pandyah5 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down