Skip to content

Commit

Permalink
added latex property to PdgArray #184
Browse files Browse the repository at this point in the history
  • Loading branch information
jacanchaplais committed Jul 18, 2024
1 parent 9ecf4de commit 5c01274
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions graphicle/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1038,14 +1038,17 @@ class PdgArray(base.ArrayBase):
.. versionchanged:: 0.2.0
Added internal numpy interfaces for greater interoperability.
.. versionchanged:: 0.4.1
``name`` property now gives unicode array. latex property added.
Parameters
----------
data : sequence[int]
The PDG codes for each particle in the point cloud.
Attributes
----------
name : ndarray[object]
name : ndarray[unicode]
String representation of particle names.
charge : ndarray[float64]
Charge for each particle in elementary units.
Expand All @@ -1069,6 +1072,8 @@ class PdgArray(base.ArrayBase):
Spatial parity for each particle.
charge_parity : ndarray[float64]
Charge parity for each particle.
latex : list[str]
LaTeX compatible representation of particle names.
Methods
-------
Expand Down Expand Up @@ -1235,7 +1240,13 @@ def __get_prop_range(self, field: str) -> base.VoidVector:

@property
def name(self) -> base.ObjVector:
return self.__get_prop("name")
# 19 is the length of longest name
return self.__get_prop("name").astype("<U19")

@property
def latex(self) -> ty.List[str]:
# 32 is the length of longest name
return self.__get_prop("latex").tolist()

@property
def charge(self) -> base.DoubleVector:
Expand Down

0 comments on commit 5c01274

Please sign in to comment.