Args:
            arr: a numpy array to be used as input to the model for prediction purposes
        Returns:
            a numpy array containing the predictions from the model
358985
def predict_array(self, arr):
        
        if not isinstance(arr, np.ndarray): raise OSError(f'Not valid numpy array')
        self.model.eval()
        return to_np(self.model(to_gpu(V(T(arr)))))
79625
def decode_arr(data):
    """"""
    data = data.encode('utf-8')
    return frombuffer(base64.b64decode(data), float64)
346231
def gdaArray(arry, dtype, numGhosts=1):
    
    a = numpy.array(arry, dtype)
    res = GhostedDistArray(a.shape, a.dtype)
    res.setNumberOfGhosts(numGhosts)
    res[:] = a
    return res
855640
def _bounds_from_array(arr, dim_name, bounds_name):
    
    # TODO: don't assume needed dimension is in axis=0
    # TODO: refactor to get rid of repetitive code
    spacing = arr.diff(dim_name).values
    lower = xr.DataArray(np.empty_like(arr), dims=arr.dims,
                         coords=arr.coords)
    lower.values[:-1] = arr.values[:-1] - 0.5*spacing
    lower.values[-1] = arr.values[-1] - 0.5*spacing[-1]
    upper = xr.DataArray(np.empty_like(arr), dims=arr.dims,
                         coords=arr.coords)
    upper.values[:-1] = arr.values[:-1] + 0.5*spacing
    upper.values[-1] = arr.values[-1] + 0.5*spacing[-1]
    bounds = xr.concat([lower, upper], dim='bounds')
    return bounds.T
1261957
def array2string(arr: numpy.ndarray) -> str:
        """"""
        shape = str(arr.shape)[1:-1]
        if shape.endswith(","):
            shape = shape[:-1]
        return numpy.array2string(arr, threshold=11) + "%s[%s]" % (arr.dtype, shape)
107540
def learn(self, grad_arr):
        '''
        

        '''
        if grad_arr.ndim > 3:
            grad_arr = grad_arr.reshape((
                grad_arr.shape[0],
                grad_arr.shape[1],
                -1
            ))
            grad_arr = grad_arr[:, -1]
        elif grad_arr.ndim == 3:
            grad_arr = grad_arr[:, -1]

        delta_arr, _, grads_list = self.__lstm_model.hidden_back_propagate(grad_arr)
        grads_list.insert(0, None)
        grads_list.insert(0, None)

        self.__lstm_model.optimize(
            grads_list,
            self.__learning_rate,
            1
        )

        return delta_arr
275617
def mad(arr):
    
    arr = np.ma.array(arr).compressed() # should be faster to not use masked arrays.
    med = np.median(arr)
    return np.median(np.abs(arr - med))
616924
function (arr) {
      for (var i = 1; i < arr.length; i++) {
        var tmp = arr[i],
          j = i;
        while (arr[j - 1] && parseInt(arr[j - 1].width, 10) > parseInt(tmp.width, 10)) {
          arr[j] = arr[j - 1];
          --j;
        }
        arr[j] = tmp;
      }

      return arr;
    }
1106459
def maximum_variation(arr):
  '''
  
  '''
  return np.max(arr, axis=0) - np.min(arr, axis=0)
1292813
def _asvector(self, arr):
        
        result = moveaxis(arr, [-2, -1], [0, 1])
        return self.domain.element(result)
133131
def array(self):
        
        return np.arange(self.start, self.stop, self.step)
1303471
function nanmin( arr ) {
	if ( !Array.isArray( arr ) ) {
		throw new TypeError( 'nanmin()::invalid input argument. Must provide an array.' );
	}
	var len = arr.length,
		min = null,
		val;

	for ( var i = 0; i < len; i++ ) {
		val = arr[ i ];
		if ( typeof val !== 'number' || val !== val ) {
			continue;
		}
		if ( min === null || val < min ) {
			min = val;
		}
	}
	return min;
}
646900
def createFromMaskedArray(cls, masked_arr):
        
        if isinstance(masked_arr, ArrayWithMask):
            return masked_arr

        check_class(masked_arr, (np.ndarray, ma.MaskedArray))

        # A MaskedConstant (i.e. masked) is a special case of MaskedArray. It does not seem to have
        # a fill_value so we use None to use the default.
        # https://docs.scipy.org/doc/numpy/reference/maskedarray.baseclass.html#numpy.ma.masked
        fill_value = getattr(masked_arr, 'fill_value', None)

        return cls(masked_arr.data, masked_arr.mask, fill_value)
1273264
def predict(model, x):
    
    if not hasattr(x, "chunks") and hasattr(x, "to_dask_array"):
        x = x.to_dask_array()
    assert x.ndim == 2
    if len(x.chunks[1]) > 1:
        x = x.rechunk(chunks=(x.chunks[0], sum(x.chunks[1])))
    func = partial(_predict, model)
    xx = np.zeros((1, x.shape[1]), dtype=x.dtype)
    dt = model.predict(xx).dtype
    return x.map_blocks(func, chunks=(x.chunks[0], (1,)), dtype=dt).squeeze()
1022732
def _array_convert(a):
    
    from numpy import ndarray
    if isinstance(a, ndarray):
        larr = a.tolist()
        if len(larr) == 1:
            return larr[0]
        else:
            return larr
    else:
        return a
652115
def bytesize(arr):
    
    byte_size = np.prod(arr.shape) * np.dtype(arr.dtype).itemsize
    return byte_size
65289
def variance(arr):
  
  avg = average(arr)
  return sum([(float(x)-avg)**2 for x in arr])/float(len(arr)-1)