

def _scale_to_res(self):
    ' Change self._A and _extent to render an image whose\n        resolution is matched to the eventual rendering.'
    ax = self.axes
    shp = self._full_res.shape
    (x0, x1, sx, y0, y1, sy) = extract_matched_slices(ax, shp)
    if ((self._bounds is not None) and (sx >= self._sx) and (sy >= self._sy) and (x0 >= self._bounds[0]) and (x1 <= self._bounds[1]) and (y0 >= self._bounds[2]) and (y1 <= self._bounds[3])):
        return
    self._A = self._full_res[y0:y1:sy, x0:x1:sx]
    self._A = cbook.safe_masked_invalid(self._A)
    if (self.origin == 'upper'):
        self.set_extent([(x0 - 0.5), (x1 - 0.5), (y1 - 0.5), (y0 - 0.5)])
    else:
        self.set_extent([(x0 - 0.5), (x1 - 0.5), (y0 - 0.5), (y1 - 0.5)])
    self._sx = sx
    self._sy = sy
    self._bounds = (x0, x1, y0, y1)
    self.changed()

dataset/ETHPy150Open glue-viz/glue/glue/external/modest_image.py ModestImage._scale_to_res/original