[yt-users] Problems with pickle

Matthew Turk matthewturk at gmail.com
Tue Mar 5 04:57:26 PST 2013


Hi Elizabeth,

I've taken a look and I think I see what the issue is.

_con_args is a property of AMRData objects that describes the
"construction arguments."  These are the arguments necessary to
rebuild a data object from its basic components -- so for a sphere,
this would be the center and the radius.  This is what yt sends to
Pickle.  It looks like con_args is somehow broken for
AMRBooleanRegion.

I believe there is a typo in the AMRBooleanRegion object.  On line
4039 (wow this file needs to be split up) of
yt/data_objects/data_containers.py, there is a line that looks like
this:

_con_args = ("regions")

I believe this should be:

_con_args = ("regions",)

This will change iteration behavior from:

>>> for i in ("regions"): print i
...
r
e
g
i
o
n
s

to:

>>> for i in ("regions",): print i
...
regions

If that works, would you mind submitting a quick pull request?

-Matt

On Mon, Mar 4, 2013 at 11:40 PM, Elizabeth Tasker
<tasker at astro1.sci.hokudai.ac.jp> wrote:
> (So e.g. trying to pickle disk data fails, but disk outer is fine)
>
>
> On Mar 4, 2013, at 11:39 PM, Elizabeth Tasker <tasker at astro1.sci.hokudai.ac.jp> wrote:
>
>> Just as an update to this problem:
>>
>> It does stem from the fact that the data was a boolean object in its dim and distant past:
>>
>> diskouter = pf.h.disk(na.array([16.0, 16.0, 16.0]), na.array([0.0,0.0,1.0]), 7.5, 100e-3/pf['kpc'])
>> diskinner = pf.h.disk(na.array([16.0, 16.0, 16.0]), na.array([0.0,0.0,1.0]), 4.5, 100e-3/pf['kpc'])
>> diskdata = pf.h.boolean([diskouter, "NOT", diskinner])
>> .
>> .
>> .
>> contours = diskdata.extract_connected_sets("Density", 1, cloud_threshold, maxv+1, log_space=True, cache=True)
>> this_agglomeration = contours[1][0][a]
>> .
>> .
>> .
>> cloud = this_agglomeration.extract_region(agglomeration_peak_assign == p)
>> .
>> .
>> .
>> cPickle.dump(cloud, file, protocol=-1)
>>
>> I also did a very old roll back and confirmed this isn't a new problem; I must have never tried to save an object that was at one point a boolean. Is there any way around this? (Apart from not using the boolean?)
>>
>> Thanks!
>>
>> Elizabeth
>>
>>
>> On Mar 4, 2013, at 10:29 PM, Elizabeth Tasker <tasker at astro1.sci.hokudai.ac.jp> wrote:
>>
>>> Hi Stephen,
>>>
>>> That method gives me exactly the same error.
>>>
>>> Either I'm doing something silly (quite probable) or perhaps there's been a change to this machinery since the last update?
>>>
>>> Elizabeth
>>>
>>>
>>> On Mar 4, 2013, at 10:18 PM, Stephen Skory <s at skory.us> wrote:
>>>
>>>> Hi Elizabeth,
>>>>
>>>>> I'm getting a problem with pickle that I've not seen before.
>>>>
>>>> Have you tried save_object / load_object?
>>>>
>>>> http://yt-project.org/doc/analyzing/objects.html#storing-and-loading-objects
>>>>
>>>> --
>>>> Stephen Skory
>>>> s at skory.us
>>>> http://stephenskory.com/
>>>> 510.621.3687 (google voice)
>>>> _______________________________________________
>>>> yt-users mailing list
>>>> yt-users at lists.spacepope.org
>>>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>>
>>> _______________________________________________
>>> yt-users mailing list
>>> yt-users at lists.spacepope.org
>>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org



More information about the yt-users mailing list