Skip to content

Apparently rounded values in Awkward Arrays, but not in individual objects #338

Answered by jpivarski
kreczko asked this question in Q&A
Discussion options

You must be logged in to vote

The data are there, with full precision, but ak.Array.__str__ minimizes the printed resolution to save screen space for all of the brackets and record key names that may be in complex data types.

>>> import numpy as np
>>> import awkward as ak
>>> import vector
>>> data = dict(
...     px=ak.Array([[10., 20., 30.], [50., 60.]]),
...     py=ak.Array([[20., 30., 40.], [60., 70.]]),
...     pz=ak.Array([[30., 40., 50.], [70., 80.]]),
... )
>>> mass = 90.0
>>> data["energy"] = np.sqrt(data["px"] ** 2 + data["py"] ** 2 + data["pz"] ** 2 + mass ** 2)
>>> p4 = vector.zip(
...     {
...         "px": data["px"],
...         "py": data["py"],
...         "pz": data["pz"],
...         "energy": data[

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kreczko
Comment options

Answer selected by kreczko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
bug (unverified) The problem described would be a bug, but needs to be triaged
2 participants
Converted from issue

This discussion was converted from issue #337 on April 24, 2023 14:59.