[yt-dev] Issue #1217: Slicing semi structured grid fails (yt_analysis/yt)

Kacper Kowalik issues-reply at bitbucket.org
Wed May 11 10:49:33 PDT 2016


New issue 1217: Slicing semi structured grid fails
https://bitbucket.org/yt_analysis/yt/issues/1217/slicing-semi-structured-grid-fails

Kacper Kowalik:

Following script:

```
#!python

import yt
import numpy as np

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])

coords, conn = yt.hexahedral_connectivity(xgrid, ygrid, zgrid)

arr = np.ones((len(xgrid)-1, len(ygrid)-1, len(zgrid)-1))

bbox = np.array([[np.min(xgrid),np.max(xgrid)],
                 [np.min(ygrid),np.max(ygrid)],
                 [np.min(zgrid),np.max(zgrid)]])
data = {"density" : arr}
ds = yt.load_hexahedral_mesh(data, conn, coords, 1.0, bbox=bbox)
yt.SlicePlot(ds, "y", "density")
```

yields

```
Traceback (most recent call last):
  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, ...]
IndexError: index 4 is out of bounds for axis 0 with size 4
```

Regression was introduced by c697901a , specifically:

```
--- a/yt/data_objects/unstructured_mesh.py
+++ b/yt/data_objects/unstructured_mesh.py
@@ -127,7 +138,7 @@
         mask = self._get_selector_mask(selector)
         count = self.count(selector)
         if count == 0: return 0
-        dest[offset:offset+count] = source.flat[mask]
+        dest[offset:offset+count] = source[mask,...]
         return count
 
     def count(self, selector):
```


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-dev-spacepope.org/attachments/20160511/257b622e/attachment.htm>


More information about the yt-dev mailing list