ADIOS icon indicating copy to clipboard operation
ADIOS copied to clipboard

Numpy: Scalar Attributes

Open ax3l opened this issue 9 years ago • 1 comments

@yyalli As in h5py, it would be important that inputs from the writer should round-trip to the reader.

Scalar attributes for example

import adios as ad
import numpy as np
fw = ad.Writer("test.bp")

fw.attrs["a1"] = 2
fw.attrs["a2"] = np.arange(0,5)
fw.close()

Should be read again as

type(f.attrs["a1"])
# SHOULD: numy.int64
# IS: numpy.ndarray
type(f.attrs["a2"])
# IS (CORRECTLY): numpy.ndarray

This already works when accessing .value of those, but making this the default cast would be ideal to allow "round-trips" of numpy data structures.

ax3l avatar Jul 17 '16 22:07 ax3l

Currently, without .value or [...] operation, it returns Attr class (or Var class for variables), such as,

type(f.attrs['a1']) <type 'adios.attr'>

If there is a variable 'v1', then,

type(f.vars['v1']) <type 'adios.var'>

Then, to get the value, we need .value or [...] operation:

type(f.attrs['a1'][...]) Or, type(f.attrs['a1'].value) returns int

I think this is "round-trip". Although, I might try to change that "f.attrs['a1']" returns "round-trip" value directly, such as,

type(f.attrs['a1']) int

One negative part is that this feature is only possible for attributes, not variables.

Do you need this feature?

Thanks, Jong

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

@yyallihttps://github.com/yyalli As in h5py, it would be important that inputs from the writer should round-trip to the reader.

Scalar attributes for example

import adios as ad import numpy as np fw = ad.Writer("test.bp")

fw.attrs["a1"] = 2 fw.attrs["a2"] = np.arange(0,5) fw.close()

Should be read again as

type(f.attrs["a1"])

SHOULD: numy.int64

IS: numpy.ndarray

type(f.attrs["a2"])

IS (CORRECTLY): numpy.ndarray

This already works when accessing .value of those, but making this the default cast would be ideal to allow "round-trips" of numpy data structures.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/ornladios/ADIOS/issues/79, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADfdB2ZvzQgt5M3IFtHLT7YOE1RGZNoHks5qWqf3gaJpZM4JOUyu.

jychoi-hpc avatar Jul 18 '16 21:07 jychoi-hpc