[Yt-dev] Bug in PlotCollectionInteractive.add_phase_sphere and add_profile_sphere

Matthew Turk matthewturk at gmail.com
Sun Oct 3 08:39:01 PDT 2010


Hi Andrew,

(Sorry for the delay in replying!  I've been out of commission for a few days.)

> I wanted to bring them problem to your attention as well as show you an
> extremely hacky attempt at solving it. The add_profile_sphere and
> add_phase_sphere methods of PlotCollectionInteractive appear to have a bug
> in them. When I do:
[snip]
> The same thing happens when I use pc.add_profile_sphere, but only with
> PlotCollectionInteractive. Using the same methods with PlotCollection works
> fine. The problem seems to be that the wrapper that "Interactifies" the
> PlotCollection methods assumes that you will not call them with "axes" or
> "figure" in the positional arguments. However, as currently coded, the
> add_phase_sphere and add_profile_sphere methods both call add_phase_object
> or add_profile_object, and when they do so they pass an axes and figure in
> the positional arguments.

Ah, yes, I see the issue, and I agree with your assessment -- changing
them to keywords instead of positional should fix the problem.

The Interactive plot collection has always been something of a
shoehorn; it tries to be a multiple-figure-manager for matplotlib, but
that's a tricky business and somewhat ill-defined anyway.  Jeff Oishi
is writing a replacement for the Plot Collection methodology that will
be more single-window focused, which should provide a much better way
of managing interactive figures.

> Probably the best way to fix this is to re-write the wrapper function to not
> assume that you don't have an axes or figure in *args, but in the meantime
> I've got mine to work just by changing add_profile_sphere and
> add_phase_sphere like so (docstring snipped)
>
>     def add_phase_sphere(self, radius, unit, fields, center = None,
> cmap=None,
>                          weight="CellMassMsun", accumulation=False,
>                          x_bins=64, x_log=True, x_bounds=None,
>                          y_bins=64, y_log=True, y_bounds=None,
>                          lazy_reader=True, id=None,
>                          axes = None, figure = None,
>                          fractional=False):
>
>         if center is None: center = self.c
>         r = radius/self.pf[unit]
>         data_source = self.pf.hierarchy.sphere(center, r)
>         p = self.add_phase_object(data_source, fields, cmap,
>                              weight, accumulation,
>                              x_bins, x_log, x_bounds,
>                              y_bins, y_log, y_bounds,
>                              lazy_reader, id, axes = axes, figure = figure,
> fractional = fractional)
>         p["Width"] = radius
>         p["Unit"] = unit
>         p["Axis"] = None
>         return p
>
> So now the call to add_phase_object takes keyword arguments instead of
> positional ones for axes and figure. I made the same change to
> add_profile_sphere, and they work for me in interactive mode now.
>

I've applied this change (and one that checks the kwargs) and pushed
to both the 'yt' branch and the 'stable' branch in hg.  Thanks very
much for this report -- and the fix!

-Matt

> Thanks,
> Andrew M
>
> _______________________________________________
> Yt-dev mailing list
> Yt-dev at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
>
>



More information about the yt-dev mailing list