Fwd: Serializing dict in jython script

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Fwd: Serializing dict in jython script

P Page-McCaw
I have a dictionary in a python script with many x,y pixel coordinates. When the dict is serialized by pickle and then opened into an iPython-notebook so that I can use numpy and pyplot, the data is corrupted. The structure of the data is maintained, but the data which comes from the results table, is mangled.

For example, in fiji the dictionary looks like this
{u'a': [[array('f', [252.0, 371.0, 273.0, 326.0, 346.0,...
but unpickled this looks like
{u'a': [[array('f', [1.180597739699512e-38, 1.1806694861808855e-38,

I'm guessing there is something about the java array 'f' type that does not serialize with pickle? The keys are ok and other text

I could write it all out to text, then back in, but surely there is a way to do the serializing more readily?

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Serializing dict in jython script

ctrueden
Hi Patrick,

Fiji currently ships with Jython 2.5.3. And I am guessing you are using at
least Python 2.7 with your iPython notebook setup?

It seems that you aren't the only one experiencing trouble mixing and
matching Python versions with pickle:
  http://stackoverflow.com/q/9313050/1207769

Probably you need to use a serialization format that is more stable, such
as JSON, as suggested in the SO post.

Regards,
Curtis

P.S. We want to update ImageJ2 & Fiji to Jython 2.7, but that entails an
upgrade to Java 7 or 8. It's in the works:
http://imagej.net/2015-06-15_-_Major_updates_in_the_works

On Fri, Nov 20, 2015 at 12:20 PM, Patrick Page-McCaw <[hidden email]>
wrote:

> I have a dictionary in a python script with many x,y pixel coordinates.
> When the dict is serialized by pickle and then opened into an
> iPython-notebook so that I can use numpy and pyplot, the data is corrupted.
> The structure of the data is maintained, but the data which comes from the
> results table, is mangled.
>
> For example, in fiji the dictionary looks like this
> {u'a': [[array('f', [252.0, 371.0, 273.0, 326.0, 346.0,...
> but unpickled this looks like
> {u'a': [[array('f', [1.180597739699512e-38, 1.1806694861808855e-38,
>
> I'm guessing there is something about the java array 'f' type that does
> not serialize with pickle? The keys are ok and other text
>
> I could write it all out to text, then back in, but surely there is a way
> to do the serializing more readily?
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html