From: Valentino A. <val...@co...> - 2005-05-12 07:14:20
|
> -----Messaggio originale----- > Da: Francesc Altet [mailto:fa...@ca...] > Inviato: mercoledì 11 maggio 2005 18.42 > A: Antonio Valentino > Cc: pyt...@li... > Oggetto: Re: [Pytables-users] Re: [ pytables-Patches-1192700 ] > Multi-dimensional HDF5 attributes > > > A Dimecres 11 Maig 2005 16:09, Antonio Valentino va escriure: > > > - When you save numarray scalars, they become saved as HDF5 scalars as > > > well. I'm hesitating here because I wonder myself whether saving them > > > as a pickle would be better. I really prefer the implemented solution > > > but, what do you think about? > > > > In my opinion saving numarray scalars as HDF5 scalars is the > best choice. > > The problem is that when you get it back from file you always have a > > Python_int or Python _float. > > Attributes can't have a "Flavor" > > That is why I suggested to map HDF5 numeric attributes onto numarray > > objects and handle all python objects using cpickle strings. > > This is absolutely unambiguous and allow the user to have the > full control > > over HDF5 attributes. > > Yeah, may be you are right. So, your proposal is to pickle numarray > scalars, so that they do not interfere with Python scalars > deserialization, isn't it? I'd like to hear more opinions on that > matter. No. The contrary. In my opinion, python integers and float should be pickled. Numarray objects, including scalars, should be saved as numeric HDF5 attributes. In this way numeric HDF5 attributes will be *always* loaded into pytables as numarray objects, and numarray objects will be *always* saved on file as numeric HDF5 attributes (H5T_NATIVE_INT, H5T_NATIVE_FLOAT and so on). Python objects, including int, float, complex, decimal.Decimal, list, tuple, dict, etc, should be saved as cpickle strings in order to not have ambiguities with numeric attributes. In this way you can write code like this leaf.attrs.uchar = na.array(1, type=na.UInt8) # --> H5T_NATIVE_UCHAR integet = 1 leaf.attrs.int = integer # --> cpickle string leaf.attrs.int32 = na.asarray(integer) # --> H5T_NATIVE_INT and then retrieve them back unambiguously. Stated that extra code is needed in order to preserve the compatibility with old pytables version, I don't know if this approach can araise other problems. I hope I have not been too much confusing. > > Ofcourse whatever solution you decide to adopt I will be happy > to help you. > > Let me know your decisions. > > Well, if you are willing to manage the case for scalar numarray > pickling, you are very welcome! > > Adéu, > > -- > >0,0< Francesc Altet http://www.carabos.com/ > V V Cárabos Coop. V. Enjoy Data > "-" ciao Antonio Valentino |