Scale ellipoid to a target volume.
321938
def scale_to_vol(self, vol):
        """"""

        f = np.exp((np.log(vol) - np.log(self.vol)) / self.n)  # linear factor
        self.expand *= f
        self.cov *= f**2
        self.am *= f**-2
        self.axlens *= f
        self.axes *= f
        self.vol = vol
1262064
def expand_squeeze_to_nd(x, n, squeeze_dim=2, expand_dim=-1):
  """"""
  if len(x.shape) > n:
    while len(x.shape) != n:
      x = tf.squeeze(x, [squeeze_dim])
  else:
    while len(x.shape) != n:
      x = tf.expand_dims(x, expand_dim)
  return x
274843
@Override
	public void scale(float x, float y, float z, float offsetX, float offsetY, float offsetZ)
	{
		translate(offsetX, offsetY, offsetZ);
		transformMatrix.scale(new Vector3f(x, y, z));
		translate(-offsetX, -offsetY, -offsetZ);
	}
1245033
def sampling_volume(self, val):
        """"""
        if self.instrument == "Vectrino" and type(val) is float:
            if val == 2.5:
                self.pdx.SamplingVolume = 0
            elif val == 4.0:
                self.pdx.SamplingVolume = 1
            elif val == 5.5:
                self.pdx.SamplingVolume = 2
            elif val == 7.0:
                self.pdx.SamplingVolume = 3
            elif val == 8.5:
                self.pdx.SamplingVolume = 4
            else:
                raise ValueError("Invalid sampling volume specified")
        elif val in range(5):
            self.pdx.SamplingVolume = val
        else:
            raise ValueError("Invalid sampling volume specified")
280862
def ScaleLarger(self):
    """"""
    newfactor = self._zoomfactor + 0.1
    if float(newfactor) > 0 and float(newfactor) < self._MAX_ZOOM:
      self._zoomfactor = newfactor
140120
def transform(data, target_wd, target_ht, is_train, box):
    """"""
    if box is not None:
        x, y, w, h = box
        data = data[y:min(y+h, data.shape[0]), x:min(x+w, data.shape[1])]

    # Resize to target_wd * target_ht.
    data = mx.image.imresize(data, target_wd, target_ht)

    # Normalize in the same way as the pre-trained model.
    data = data.astype(np.float32) / 255.0
    data = (data - mx.nd.array([0.485, 0.456, 0.406])) / mx.nd.array([0.229, 0.224, 0.225])

    if is_train:
        if random.random() < 0.5:
            data = nd.flip(data, axis=1)
        data, _ = mx.image.random_crop(data, (224, 224))
    else:
        data, _ = mx.image.center_crop(data, (224, 224))

    # Transpose from (target_wd, target_ht, 3)
    # to (3, target_wd, target_ht).
    data = nd.transpose(data, (2, 0, 1))

    # If image is greyscale, repeat 3 times to get RGB image.
    if data.shape[0] == 1:
        data = nd.tile(data, (3, 1, 1))
    return data.reshape((1,) + data.shape)
828941
def ScaleSmaller(self):
    """"""
    newfactor = self._zoomfactor - 0.1
    if float(newfactor) > 0 and float(newfactor) < self._MAX_ZOOM:
      self._zoomfactor = newfactor
578969
def _call(self, x):
        """"""
        out = x.asarray().ravel()[self._indices_flat]

        if self.variant == 'point_eval':
            weights = 1.0
        elif self.variant == 'integrate':
            weights = getattr(self.domain, 'cell_volume', 1.0)
        else:
            raise RuntimeError('bad variant {!r}'.format(self.variant))

        if weights != 1.0:
            out *= weights

        return out
975485
def unit_targeting(w, k):
  """"""
  k = tf.to_int32(k)
  w_shape = shape_list(w)
  size = tf.to_int32(tf.reduce_prod(w_shape[:-1]))
  w = tf.reshape(w, [size, w_shape[-1]])

  norm = tf.norm(w, axis=0)
  thres = tf.contrib.framework.sort(norm, axis=0)[k]
  mask = to_float(thres >= norm)[None, :]
  mask = tf.tile(mask, [size, 1])

  return tf.reshape(mask, w_shape)
627944
def scale(self, dx=1.0, dy=1.0):
        '''
        

        '''
        self.width *= dx
        self.height *= dy
943640
public static void scale( double alpha , DMatrix3 a ) {
        a.a1 *= alpha;
        a.a2 *= alpha;
        a.a3 *= alpha;
    }
1002041
def _submarine_2d_smooth(space, taper):
    """"""

    def logistic(x, c):
        """Smoothed step function from 0 to 1, centered at 0."""
        return 1. / (1 + np.exp(-c * x))

    def blurred_ellipse(x):
        """Blurred characteristic function of an ellipse.

        If ``space.domain`` is a rectangle ``[0, 1] x [0, 1]``,
        the ellipse is centered at ``(0.6, 0.3)`` and has half-axes
        ``(0.4, 0.14)``. For other domains, the values are scaled
        accordingly.
        """
        halfaxes = np.array([0.4, 0.14]) * space.domain.extent
        center = np.array([0.6, 0.3]) * space.domain.extent
        center += space.domain.min()

        # Efficiently calculate |z|^2, z = (x - center) / radii
        sq_ndist = np.zeros_like(x[0])
        for xi, rad, cen in zip(x, halfaxes, center):
            sq_ndist = sq_ndist + ((xi - cen) / rad) ** 2

        out = np.sqrt(sq_ndist)
        out -= 1
        # Return logistic(taper * (1 - |z|))
        return logistic(out, -taper)

    def blurred_rect(x):
        """Blurred characteristic function of a rectangle.

        If ``space.domain`` is a rectangle ``[0, 1] x [0, 1]``,
        the rect has lower left ``(0.56, 0.4)`` and upper right
        ``(0.76, 0.6)``. For other domains, the values are scaled
        accordingly.
        """
        xlower = np.array([0.56, 0.4]) * space.domain.extent
        xlower += space.domain.min()
        xupper = np.array([0.76, 0.6]) * space.domain.extent
        xupper += space.domain.min()

        out = np.ones_like(x[0])
        for xi, low, upp in zip(x, xlower, xupper):
            length = upp - low
            out = out * (logistic((xi - low) / length, taper) *
                         logistic((upp - xi) / length, taper))
        return out

    out = space.element(blurred_ellipse)
    out += space.element(blurred_rect)
    return out.ufuncs.minimum(1, out=out)
1839
public static double volumeScaled(SpatialComparable box, double scale) {
    final int dim = box.getDimensionality();
    double vol = 1.;
    for(int i = 0; i < dim; i++) {
      double delta = box.getMax(i) - box.getMin(i);
      if(delta == 0.) {
        return 0.;
      }
      vol *= delta * scale;
    }
    return vol;
  }
1271364
def __execute_scale(self, surface, size_to_scale_from):
        """"""
        x = size_to_scale_from[0] * self.__scale[0]
        y = size_to_scale_from[1] * self.__scale[1]
        scaled_value = (int(x), int(y))

##        #Find out what scaling technique we should use.
##        if self.image.get_bitsize >= 24:
##            #We have sufficient bit depth to run smooth scale
##            self.image = pygame.transform.smoothscale(self.image, scaled_value)
##        else:
            ##Surface doesn't support smooth scale, revert to regular scale
        self.image = pygame.transform.scale(self.image, scaled_value)

        self.__resize_surface_extents()
1372147
def update(self, pointvol):
        """"""

        # Check if we should use the provided pool for updating.
        if self.use_pool_update:
            pool = self.pool
        else:
            pool = None

        # Update the ellipsoid.
        self.ell.update(self.live_u, pointvol=pointvol, rstate=self.rstate,
                        bootstrap=self.bootstrap, pool=pool)
        if self.enlarge != 1.:
            self.ell.scale_to_vol(self.ell.vol * self.enlarge)

        return copy.deepcopy(self.ell)
747151
def transform(self, X):
        """"""
        if not self.is_fit:
            raise ValueError("The scaler has not been fit yet.")
        return (X-self.mean) / (self.std + 10e-7)
1109019
def weight_targeting(w, k):
  """"""
  k = tf.to_int32(k)
  w_shape = shape_list(w)
  size = tf.to_int32(tf.reduce_prod(w_shape[:-1]))
  w = tf.reshape(w, [size, w_shape[-1]])

  transpose_w = tf.transpose(w)
  thres = tf.contrib.framework.sort(tf.abs(transpose_w), axis=1)[:, k]
  mask = to_float(thres[None, :] >= tf.abs(w))

  return tf.reshape(mask, w_shape)