[yt-users] Error annotating particles
Nathan Goldbaum
nathan12343 at gmail.com
Tue Jul 18 12:13:10 PDT 2017
Hi Jose,
I'm able to reproduce this error on yt 3.3.5, thank you for the report.
It looks like this was fixed in the development branch a few months ago:
https://github.com/yt-project/yt/commit/7606a8e38cae62dcc84d2b14fc20e8933bb302b1
Unfortunately that fix didn't make it into yt 3.3.5. We're planning to get
yt 3.4 out ASAP, which will include this fix.
To work around this you can explicitly set stride=1 (not 1.0) in your call
to annotate_particles.
Downgrading to numpy 1.11 would also fix this (using a float to index a
numpy array was made an error in numpy 1.12). Compiling yt from source on
the git master branch would also fix it.
Hope that helps,
Nathan
On Tue, Jul 18, 2017 at 1:47 PM, José Mauricio Utreras <
jutreras at ug.uchile.cl> wrote:
> Hi yt-users,
>
> I'm using an old and simple script to overplot particles but now is not
> working.
>
> Cheers!
>
> José Utreras
>
> slc=yt.SlicePlot(ds, 'z','density', width=(25,'kpc'))
> slc.annotate_particles(width=20*kpc)
>
>
> ~/miniconda3/lib/python3.6/site-packages/yt/visualization/plot_window.py in run_callbacks(self) 1006 try:-> 1007 callback(cbw) 1008 except YTDataTypeUnsupported as e:
> ~/miniconda3/lib/python3.6/site-packages/yt/visualization/plot_modifications.py in _check_geometry(self, plot) 53 if supp is None or geom in supp:---> 54 return func(self, plot) 55 if cs in ("axis", "figure") and "force" not in supp:
> ~/miniconda3/lib/python3.6/site-packages/yt/visualization/plot_modifications.py in __call__(self, plot) 1574 px, py = self.convert_to_plot(plot,-> 1575 [np.array(particle_x[gg][::self.stride]), 1576 np.array(particle_y[gg][::self.stride])])
> ~/miniconda3/lib/python3.6/site-packages/yt/units/yt_array.py in __getitem__(self, item) 1162 def __getitem__(self, item):-> 1163 ret = super(YTArray, self).__getitem__(item) 1164 if ret.shape == ():
> TypeError: slice indices must be integers or None or have an __index__ method
>
> During handling of the above exception, another exception occurred:
> YTPlotCallbackError Traceback (most recent call last)~/miniconda3/lib/python3.6/site-packages/IPython/core/formatters.py in __call__(self, obj) 334 method = get_real_method(obj, self.print_method) 335 if method is not None:--> 336 return method() 337 return None 338 else:
> ~/miniconda3/lib/python3.6/site-packages/yt/visualization/plot_container.py in newfunc(*args, **kwargs) 76 # it is the responsibility of _setup_plots to 77 # call args[0].run_callbacks()---> 78 args[0]._setup_plots() 79 rv = f(*args, **kwargs) 80 return rv
> ~/miniconda3/lib/python3.6/site-packages/yt/visualization/plot_window.py in _setup_plots(self) 954 955 self._set_font_properties()--> 956 self.run_callbacks() 957 self._plot_valid = True 958
> ~/miniconda3/lib/python3.6/site-packages/yt/visualization/plot_window.py in run_callbacks(self) 1011 six.reraise(YTPlotCallbackError, 1012 YTPlotCallbackError(callback._type_name, e),-> 1013 sys.exc_info()[2]) 1014 for key in self.frb.keys(): 1015 if key not in keys:
> ~/miniconda3/lib/python3.6/site-packages/six.py in reraise(tp, value, tb) 683 value = tp() 684 if value.__traceback__ is not tb:--> 685 raise value.with_traceback(tb) 686 raise value 687
> ~/miniconda3/lib/python3.6/site-packages/yt/visualization/plot_window.py in run_callbacks(self) 1005 callback = CallbackMaker(*args[1:], **kwargs) 1006 try:-> 1007 callback(cbw) 1008 except YTDataTypeUnsupported as e: 1009 six.reraise(YTDataTypeUnsupported, e)
> ~/miniconda3/lib/python3.6/site-packages/yt/visualization/plot_modifications.py in _check_geometry(self, plot) 52 cs = getattr(self, "coord_system", None) 53 if supp is None or geom in supp:---> 54 return func(self, plot) 55 if cs in ("axis", "figure") and "force" not in supp: 56 return func(self, plot)
> ~/miniconda3/lib/python3.6/site-packages/yt/visualization/plot_modifications.py in __call__(self, plot) 1573 if gg.sum() == 0: return 1574 px, py = self.convert_to_plot(plot,-> 1575 [np.array(particle_x[gg][::self.stride]), 1576 np.array(particle_y[gg][::self.stride])]) 1577 plot._axes.scatter(px, py, edgecolors='None', marker=self.marker,
> ~/miniconda3/lib/python3.6/site-packages/yt/units/yt_array.py in __getitem__(self, item) 1161 1162 def __getitem__(self, item):-> 1163 ret = super(YTArray, self).__getitem__(item) 1164 if ret.shape == (): 1165 return YTQuantity(ret, self.units, bypass_validation=True)
> YTPlotCallbackError: annotate_particles callback failed with the following error: slice indices must be integers or None or have an __index__ method
>
>
>
>
>
> _______________________________________________
> 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/20170718/714c653e/attachment-0001.htm>
More information about the yt-users
mailing list