openPMD / openPMD-api

:floppy_disk: C++ & Python API for Scientific I/O
https://openpmd-api.readthedocs.io
GNU Lesser General Public License v3.0
138 stars 51 forks source link

Update __repr__ method of major objects in openPMD hierarchy #1476

Closed franzpoeschel closed 1 year ago

franzpoeschel commented 1 year ago

With this PR:

>>> import openpmd_api as io
>>> s = io.Series("simData_%T.bp5", io.Access.read_only)
>>> s
<openPMD.Series at './simData_%T.bp5' with 6 iteration(s) and 12 attributes>
>>> s.iterations
<openPMD.Iteration_Container with 6 entries and 0 attribute(s)>
>>> s.iterations[100]
<openPMD.Iteration at t = '6.400000e-15 s' with 20 attributes>
>>> s.iterations[100].meshes
<openPMD.Mesh_Container with 5 entries and 5 attribute(s)>
>>> s.iterations[100].meshes["E"]
<openPMD.Mesh record with '3' record component(s) and 9 attributes>
>>> s.iterations[100].meshes["E"]["x"]
<openPMD.Record_Component of type 'FLOAT' and with extent [128, 3072, 128]>
>>> s.iterations[100].particles
<openPMD.Particle_Container with 1 entry and 0 attribute(s).>
>>> s.iterations[100].particles["e"]
<openPMD.ParticleSpecies with 8 record(s) and 5 attribute(s)>
>>> s.iterations[100].particles["e"]["position"]
<openPMD.Record of 3 component(s) and 4 attribute(s)>
>>> s.iterations[100].particles["e"]["position"]["x"]
<openPMD.Record_Component of type 'FLOAT' and with extent [91611546]>
>>> s.iterations[100].particles["e"].particle_patches
<openPMD.Particle_Patches with 4 records and 0 attribute(s)>
>>> s.iterations[100].particles["e"].particle_patches["offset"]
<openPMD.Patch_Record_Component_Container with 3 entries and 1 attribute(s)>
>>> s.iterations[100].particles["e"].particle_patches["offset"]["x"]
<openPMD.Patch_Record_Component of type 'ULONG' and with extent [1]>

(Plural (s) is not in parentheses where the openPMD standard requires more than one entry)

This fixes the UX bug last seen here.

franzpoeschel commented 1 year ago

Adding API:new label since this adds an Access access member to MyPath