Hi Doug,

My vote is for number four.


On Jul 23, 2013 9:17 AM, "Douglas Harvey Rudd" <drudd@uchicago.edu> wrote:
Hi all,

In writing test cases for the slice selector I discovered that the reslice function of YTSliceBase appears to be broken due to caching at several levels.

1) the selector object stores the slice coordinate and was never updated
2) the grid selection is cached
3) the cell mask (created by fill_mask) is only updated when the selector id changes

I fixed 1) and 2) by overloading the clear_data function in YTSelectionDataContainer:

    def clear_data(self):
        Clears out all data from the YTSelectionDataContainer instance, freeing memory.
        self._selector = None
        self._current_chunk = None

and replaced the call to self.field_data.clear() in YTSliceBase.reslice with self.clear_data()

This forces the selector to be recreated when it is next requested.  Unfortunately the problem persisted, inconsistently, and I tracked it down to 3).  The id of the newly created selector was sometimes identical to the one prior to the reslice command.  In the grid_patch hierarchy, the cell mask is only recreated if the id of the selector object has changed, and so in this case an old mask persisted.

I see several options for solving the problem:

1) replace using the python id function with a random identifier or hash of the actual selector data, to ensure it detects when the parameters have changed
2) reach into the hierarchy from the clear_data function and erase the cached cell mask
3) add a check in the hierarchy to detect if the chunking has changed along with the selector (not sure how this could be done, but probably a good idea anyway, for consistency)
4) remove the reslice function and prevent selection data containers from changing after creation


Douglas Rudd
Scientific Computing Consultant
Research Computing Center

yt-dev mailing list