[yt-users] Pickle vs. _type_name

david collins dcollins4096 at gmail.com
Mon Jun 17 11:35:48 PDT 2013


Thanks for the suggestion, Matt.

I'm still getting an error-- I added the following to data_containers.py:

<code>
class InLineExtractedRegionBase(AMR3DData):
    """    In-line extracted regions accept a base region and a set of
field_cuts to
    determine which points in a grid should be included.
    """
    _con_args = ("base_region", "field_cuts")
    _type_name = "cut_region"
</code>

and now I get the error

AttributeError: 'InLineExtractedRegionBase' object has no attribute
'base_region'

  File "/nics/b/home/collins/yt2.0/fPickle.py", line 15, in dump
    output = cPickle.dump(object,file,*args,**kwargs)
  File
"/nics/b/home/collins/local_2013_03_12/src/yt-dave-hg-hangnail/yt/data_objects/data_containers.py",
line 407, in __reduce__
    [getattr(self, n) for n in self._con_args] +
AttributeError: 'InLineExtractedRegionBase' object has no attribute
'base_region'

Thanks a ton,
d.



On Mon, Jun 17, 2013 at 11:34 AM, Matthew Turk <matthewturk at gmail.com>wrote:

> Hi Dave,
>
> I think it needs the following items:
>
> _con_args = ("base_region", "field_cuts")
> _type_name = "cut_region"
>
> in the class definition and I think it should be good to go.
>
> -Matt
>
> On Mon, Jun 17, 2013 at 1:32 PM, David Collins <dcollins4096 at gmail.com>
> wrote:
> > Hi, all--
> >
> > I'm trying to pickle a dataset I made with cut_region.  This fails on the
> > call to __reduce__ since the cut_region doesn't have a _type_name
> attribute.
> > Is there an easy way to give _type_names to cut regions in general, or
> > should I clone the __reduce__ method for InLineExtractedRegionBase?
> >
> > I generate the object like this:
> >
> >>> region = pf.h.region(Center,Left,Right)
> >>> cut_region = region.cut_region(['grid[some_field] == some_value'})
> >>> file = open(args)
> >>> cPickle.dump(cut_region,file)
> >
> >  which gives the following error:
> >
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in <module>
> >   File "/nics/b/home/collins/yt2.0/fPickle.py", line 15, in dump
> >     output = cPickle.dump(object,file,*args,**kwargs)
> >   File
> >
> "/nics/b/home/collins/local_2013_03_12/src/yt-dave/yt/data_objects/data_containers.py",
> > line 407, in __reduce__
> >     [getattr(self, n) for n in self._con_args] +
> > AttributeError: 'InLineExtractedRegionBase' object has no attribute
> > '_type_name'
> >
> >
> > Thanks!
> > d.
> >
> > _______________________________________________
> > 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20130617/e57aca46/attachment.html>


More information about the yt-users mailing list