returns the shape after scaling (should be the same as ndimage.zoom
504105
def _scale_shape(dshape, scale = (1,1,1)):
    """"""
    nshape = np.round(np.array(dshape) * np.array(scale))
    return tuple(nshape.astype(np.int))
918789
def size_when_fitting(target, dimensions = get_base_dimensions)
      zoom = [
        dimensions[:width].to_f / target[:width],
        dimensions[:height].to_f / target[:height]
      ].max

      if zoom == 0.0
        width = target[:width]
        height = target[:height]
      else
        width = (dimensions[:width] / zoom).round
        height = (dimensions[:height] / zoom).round
      end

      {width: width.to_i, height: height.to_i}
    end
1065355
def get_size(item):
    """"""
    if isinstance(item, (list, set, tuple, dict)):
        return len(item)
    elif isinstance(item, (ndarray, MaskedArray)):
        return item.shape
    elif isinstance(item, Image):
        return item.size
    if isinstance(item, (DataFrame, Index, Series)):
        return item.shape
    else:
        return 1
770272
def shape(self):
        ""
        keys = self.keys()
        if self.ndims == 1:
            return (len(keys), 1)
        return len(set(k[0] for k in keys)), len(set(k[1] for k in keys))
172847
def reshape(self, *dims):
        """"""
        shape = _dims2shape(*dims)
        if _volume(shape) != self.size:
            raise ValueError("expected shape with equal volume")
        return self.__class__(self._items, shape, self.ftype)
1351279
def shape(self):
        
        return tuple(len(self._get_axis(a)) for a in self._AXIS_ORDERS)
465337
def get_shape(cursor, name):
    """"""
    cursor.execute('select * from [%s]' % name)
    inds = cursor.description[-1][0][1:].split('_')
    return tuple([int(i) for i in inds])
1105012
def rebin_scale(a, scale=1):
    """"""

    newshape = tuple((side * scale) for side in a.shape)

    return rebin(a, newshape)
386508
def _zoom(scale:uniform=1.0, row_pct:uniform=0.5, col_pct:uniform=0.5):
    ""
    s = 1-1/scale
    col_c = s * (2*col_pct - 1)
    row_c = s * (2*row_pct - 1)
    return _get_zoom_mat(1/scale, 1/scale, col_c, row_c)
745921
def resize(self, shape):
        
        if self.is_empty():
            raise ValueError("Cannot resize an empty image")

        factor = [1, 1]
        zoom = [True, True]
        zoom[0] = shape[0] >= self.height
        zoom[1] = shape[1] >= self.width

        if zoom[0]:
            factor[0] = shape[0] * 1.0 / self.height
        else:
            factor[0] = self.height * 1.0 / shape[0]
        if zoom[1]:
            factor[1] = shape[1] * 1.0 / self.width
        else:
            factor[1] = self.width * 1.0 / shape[1]

        if(int(factor[0]) != factor[0] or
           int(factor[1]) != factor[1]):
            raise ValueError("Resize not of integer factor!")

        factor[0] = int(factor[0])
        factor[1] = int(factor[1])

        i = 0
        for chn in self.channels:
            if zoom[0]:
                chn = chn.repeat([factor[0]] * chn.shape[0], axis=0)
            else:
                chn = chn[[idx * factor[0]
                           for idx in range(int(self.height / factor[0]))],
                          :]
            if zoom[1]:
                self.channels[i] = chn.repeat([factor[1]] * chn.shape[1],
                                              axis=1)
            else:
                self.channels[i] = chn[:,
                                       [idx * factor[1]
                                        for idx in range(int(self.width /
                                                             factor[1]))]]

            i = i + 1

        self.height = self.channels[0].shape[0]
        self.width = self.channels[0].shape[1]
        self.shape = self.channels[0].shape
1265497
def getDimensionForImage(filename, maxsize):
    """"""
    try:
        from PIL import Image
    except ImportError:
        return None
    img = Image.open(filename)
    width, height = img.size
    if width > maxsize[0] or height > maxsize[1]:
        img.thumbnail(maxsize)
        out.info("Downscaled display size from %s to %s" % ((width, height), img.size))
    return img.size
961624
def _shape(self):
        
        hdu = self.open()
        _shape = hdu.shape
        if not self.inmemory:
            self.close()
            del hdu
        return _shape
1265010
def scaleX(self, x):
        ''
        return round(self.plotviewBox.xmin+(x-self.visibleBox.xmin)*self.xScaler)
946430
def get_shape(self, ds_id, ds_info):
        """"""
        var_path = ds_info['file_key']
        shape = self[var_path + '/shape']
        if ((ds_info.get('standard_name') == "longitude" or ds_info.get('standard_name') == "latitude") and
                ds_id.resolution == 10000):
            return shape[0], int(shape[1] / 2)
        return shape
557344
def _get_zoom_mat(sw:float, sh:float, c:float, r:float)->AffineMatrix:
    ""
    return [[sw, 0,  c],
            [0, sh,  r],
            [0,  0, 1.]]
301516
def full_size(self):
        ''''''
        self.dragpos = wx.Point(0, 0)
        self.zoom = 1.0
        self.need_redraw = True
234428
def scale(self):
        
        # use vertices peak-peak rather than exact extents
        scale = float((self.vertices.ptp(axis=0) ** 2).sum() ** .5)
        return scale