<html><body>
<p>New issue 1217: Slicing semi structured grid fails <a href="https://bitbucket.org/yt_analysis/yt/issues/1217/slicing-semi-structured-grid-fails">https://bitbucket.org/yt_analysis/yt/issues/1217/slicing-semi-structured-grid-fails</a></p>
<p>Kacper Kowalik:</p>
<p>Following script:</p>
<p>``` #!python</p>
<p>import yt import numpy as np</p>
<p>xgrid = np.array([-1, -0.65, 0, 0.65, 1]) ygrid = np.array([-1, 0, 1]) zgrid = np.array([-1, -0.447, 0.447, 1])</p>
<p>coords, conn = yt.hexahedral_connectivity(xgrid, ygrid, zgrid)</p>
<p>arr = np.ones((len(xgrid)-1, len(ygrid)-1, len(zgrid)-1))</p>
<p>bbox = np.array([[np.min(xgrid),np.max(xgrid)],</p>
<pre>[np.min(ygrid),np.max(ygrid)],
[np.min(zgrid),np.max(zgrid)]])</pre>
<p>data = {"density" : arr} ds = yt.load_hexahedral_mesh(data, conn, coords, 1.0, bbox=bbox) yt.SlicePlot(ds, “y”, “density”) ```</p>
<p>yields</p>
<p>``` Traceback (most recent call last):</p>
<pre>File "ala.py", line 17, in <module>
  yt.SlicePlot(ds, "y", "density")
File "/home/xarth/codes/yt-my/yt/visualization/plot_window.py", line 1867, in SlicePlot
  return AxisAlignedSlicePlot(ds, normal, fields, *args, **kwargs)
File "/home/xarth/codes/yt-my/yt/visualization/plot_window.py", line 1240, in __init__
  slc.get_data(fields)
File "/home/xarth/codes/yt-my/yt/data_objects/data_containers.py", line 1172, in get_data
  fluids, self, self._current_chunk)
File "/home/xarth/codes/yt-my/yt/geometry/geometry_handler.py", line 245, in _read_fluid_fields
  chunk_size)
File "/home/xarth/codes/yt-my/yt/frontends/stream/io.py", line 229, in _read_fluid_selection
  ind += g.select(selector, ds, rv[field], ind) # caches
File "/home/xarth/codes/yt-my/yt/data_objects/unstructured_mesh.py", line 142, in select
  dest[offset:offset+count] = source[mask, ...]</pre>
<p>IndexError: index 4 is out of bounds for axis 0 with size 4 ```</p>
<p>Regression was introduced by c697901a , specifically:</p>
<p>``` --- a/yt/data_objects/unstructured_mesh.py +++ b/yt/data_objects/unstructured_mesh.py @@ -127,7 +138,7 @@</p>
<pre>mask = self._get_selector_mask(selector)
count = self.count(selector)
if count == 0: return 0</pre>
<ul><li><p>dest[offset:offset+count] = source.flat[mask]</p></li></ul>
<p>+        dest[offset:offset+count] = source[mask,…]</p>
<pre>        return count

    def count(self, selector):</pre>
<p>```</p>

<img src="http://link.bitbucket.org/wf/open?upn=JlBWjyZTyKwhM1rBKe-2BcAdFPwdECN4PBooLGVSVl7EJewO6BQXPyOz42riH61MS4nqt0hUIde-2FAJB09ElKcUJo2Ol6skDRcbHFARLViV7bmJNSg-2Bsm-2BI0JvD3jn78ym3d0yhaVM24ZLtmErVU5KC2PxuRrYy0CwVLFPhzB-2FTLFkQEEK7eotSi55el6bje2eFL3C8NVKA4fuuMtSJeDqdEEDyPRpMU0KENn6OSyHQfH8-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;"/>
</body></html>