ADIOS icon indicating copy to clipboard operation
ADIOS copied to clipboard

Numpy: Group .keys() Attribute

Open ax3l opened this issue 9 years ago • 3 comments

Can we please add a .keys() attribute to the group object? (update: done) The idea is to list always the next level of groups and variables (but not attributes), e.g., as one would select them via [].

For a file like

$ bpls -a example.bp
  real                /data/0/fields/E/x                            {10240, 8320}
  real                /data/0/fields/E/y                            {10240, 8320}
  real                /data/0/fields/e_chargeDensity                {10240, 8320}
[...]
  unsigned long long  /data/0/particles/e/particles_info            {40}
  real                /data/0/particles/e/position/x                {5646994}
  real                /data/0/particles/e/position/y                {5646994}
  real                /data/0/particles/e/momentum/x                {5646994}
[...]
  double              /data/0/fields/E/x/sim_unit                   attr
  double              /data/0/fields/E/y/sim_unit                   attr
  double              /data/0/fields/e_chargeDensity/sim_unit       attr
[...]
  unsigned integer    /data/0/iteration                             attr
  unsigned integer    /data/0/sim_slides                            attr
  real                /data/0/delta_t                               attr
  real                /data/0/cell_width                            attr
  real                /data/0/cell_height                           attr
[...]

it should work like this:

import adios as ad

f = ad.File("example.bp")

g = f["data/0"]
g.keys()
# fields, particles

g["fields"].keys()
# FieldE, e_chargeDensity

# the file object is identical to group "/" and should have the same added functionality
f.keys()
# data

(Note: attributes should not be listed since they are explicitly accessed via g.attrs.keys().)

ax3l avatar May 30 '16 08:05 ax3l

@yyalli this is an other issue we need to work on to make groups useful in the numpy wrapper

ax3l avatar Jul 18 '16 00:07 ax3l

currently, .keys() on a group lists recursively all members as in ls -R but it should only behave as a simple ls.

in other word: remove everything from the .keys() result that has an other / in it. (Of course, one can still access those filtered results via [...] directly, but keys() should not show them since it shall look like a fs tree.)

ax3l avatar Jul 18 '16 00:07 ax3l

.keys() has been implemented to support tab-completion for ipython. Instead of .keys(), I have created .dirs() for this purpose. So, now you can do, something like, g.dirs() f.dirs()

Will this work for you?

Jong Youl Choi Scientific Data Group Computer Science and Math Division Oak Ridge National Laboratory Homepage: http://www.ornl.gov/~jyc/

On Jul 17, 2016, at 8:04 PM, Axel Huebl <[email protected]mailto:[email protected]> wrote:

currently, .keys() on a group lists recursively all members as in ls -R but it should only behave as a simple ls.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/ornladios/ADIOS/issues/72#issuecomment-233212077, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADfdB-7hK4lJWdmASmjfwZhvpSpOsKBWks5qWsMYgaJpZM4Ipldc.

jychoi-hpc avatar Jul 19 '16 20:07 jychoi-hpc