[yt-dev] kwargs for SlicePlot and ProjectionPlot?

Matthew Turk matthewturk at gmail.com
Sun Jan 13 16:04:00 PST 2013


Hey Andrew,

On Sun, Jan 13, 2013 at 6:45 PM, Andrew Myers <atmyers at berkeley.edu> wrote:
> Hi Folks,
>
> I was wondering if there are any objections (particularly from Nathan) to
> adding an optional **kwargs argument to SlicePlot and ProjectionPlot, so
> that we can pass in field parameters like this:
>
> pw = SlicePlot(pf, 2, 'GravitationalForceMag', center=c, width=(1e4, 'au'),
> particle_data=pd)
>
> instead of the (very slighty) more clunky:
>
> slice = pf.h.slice(2, c[2], ['GravitationalForceMag'], particle_data=pd)
> pw = slice.to_pw('GravitationalForceMag', center=c, width=(1e4, 'au'))
>
> I think it would be nice to able to use the same syntax to generate slices
> and projections whether or not a derived field requires extra field
> parameters.

This would be nice.  However, sine in 3.0 kwargs have been replaced
with an explicit:

field_parameters = {'particle_data': pd}

type call in the constructor, I would prefer we go with the same thing
here.  In general I'm less into adding complexity to the APIs for
things like this, but for this use case I think it's manifestly better
to allow it.  So I'd say yes, with the caveat that we should be doing:

pw = SlicePlot(pf, 2, 'GravitationalForceMag', center=c, width=(1e4,
'au'), field_parameters=dict(particle_data=pd))

and then passing the field_parameters as kwargs to the data object
creation.  This way when 3.0 is the main use case, we only have to
change from passing kwargs to the data object construction to passing
the field_parameters dict itself.

Would that be okay?

-Matt

>
> Thanks,
> Andrew
>
>
> _______________________________________________
> 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