Receive the slice from processor pcoord - offset.

    Args:
      x: a LaidOutTensor
      mesh_axis: an integer
      offset: an integer
      wrap: a boolean. If True, then wrap around. Otherwise, pad with zeros.
512982
def shift_by_n_processors(self, x, mesh_axis, offset, wrap):
    
    n = self.shape[mesh_axis].size
    source_pcoord = []
    for i in xrange(n):
      c = i - offset
      if c != c % n:
        if wrap:
          c = c % n
        else:
          c = None
      source_pcoord.append(c)
    return self.receive(x, mesh_axis, source_pcoord)
994248
def _get_slice_axis(self, slice_obj, axis=None):
        
        if axis is None:
            axis = self.axis or 0

        obj = self.obj
        if not need_slice(slice_obj):
            return obj.copy(deep=False)

        labels = obj._get_axis(axis)
        indexer = labels.slice_indexer(slice_obj.start, slice_obj.stop,
                                       slice_obj.step, kind=self.name)

        if isinstance(indexer, slice):
            return self._slice(indexer, axis=axis, kind='iloc')
        else:
            return self.obj._take(indexer, axis=axis)
1167285
def flip(a, axis):
    
    if not hasattr(a, 'ndim'):
        a = np.asarray(a)
    indexer = [slice(None)] * a.ndim
    try:
        indexer[axis] = slice(None, None, -1)
    except IndexError:
        raise ValueError('axis={} is invalid for the {}-dimensional input '
                         'array'.format(axis, a.ndim))
    return a[tuple(indexer)]
751667
def slice_global_to_local(self, index_slice, axis=0):
        
        if index_slice.stop < self.__mask[axis].start+self.__halos[0][axis]:
            return None

        if index_slice.start > self.__mask[axis].stop-self.__halos[1][axis]:
            return None

        local_start = self.int_global_to_local_start(index_slice.start, axis)
        local_stop = self.int_global_to_local_stop(index_slice.stop, axis)

        return slice(local_start,local_stop,index_slice.step)
456599
def _fix_slice(self, inputs, new_attr):
        """"""
        begin = new_attr.get('begin')
        end = new_attr.get('end')
        axes = new_attr.get('axis', tuple(range(len(begin))))
        slice_op = mx.sym.slice_axis(inputs[0], axis=axes[0], begin=begin[0], end=end[0])
        if len(axes) > 1:
            for i, axis in enumerate(axes):
                slice_op = mx.sym.slice_axis(slice_op, axis=axis, begin=begin[i], end=end[i])
        return slice_op
1055736
public void setOffset(float offset, final Axis axis) {
        if (!equal(mOffset.get(axis), offset)) {
            mOffset.set(offset, axis);
            if (mContainer != null) {
                mContainer.onLayoutChanged(this);
            }
        }
    }
1189792
public float get(Layout.Axis axis) {
        switch (axis) {
            case X:
                return x;
            case Y:
                return y;
            case Z:
                return z;
            default:
                throw new RuntimeAssertion("Bad axis specified: %s", axis);
        }
    }
1349053
def _zeropad(sig, N, axis=0):
    """"""
    # ensures concatenation dimension is the first
    sig = np.moveaxis(sig, axis, 0)
    # zero pad
    out = np.zeros((sig.shape[0] + N,) + sig.shape[1:])
    out[:sig.shape[0], ...] = sig
    # put back axis in place
    out = np.moveaxis(out, 0, axis)
    return out
973681
def positionlesscrop(self,x,y,sheet_coord_system):
        
        slice_inds = self.findinputslice(
            sheet_coord_system.sheet2matrixidx(x,y),
            self.shape_on_sheet(), sheet_coord_system.shape)

        self.set(slice_inds)
70887
def slice_begin(self, tensor_shape, pnum):
    
    tensor_layout = self.tensor_layout(tensor_shape)
    coordinates = pnum_to_processor_coordinates(self.shape, pnum)
    ret = []
    for dim_size, mesh_axis in zip(
        tensor_shape.to_integer_list, tensor_layout.tensor_axis_to_mesh_axis):
      if mesh_axis is None:
        ret.append(0)
      else:
        ret.append(
            dim_size // self.shape[mesh_axis].size * coordinates[mesh_axis])
    return ret
1210953
def process_slice(self, b_rot90=None):
        '''
        
        '''
        if b_rot90:
            self._Mnp_2Dslice = np.rot90(self._Mnp_2Dslice)
        if self.func == 'invertIntensities':
            self.invert_slice_intensities()
1008788
def _call(self, x, out=None):
        """"""
        # TODO: pass reasonable options on to the interpolator
        def nearest(arg, out=None):
            """Interpolating function with vectorization."""
            if is_valid_input_meshgrid(arg, self.grid.ndim):
                input_type = 'meshgrid'
            else:
                input_type = 'array'

            interpolator = _NearestInterpolator(
                self.grid.coord_vectors, x, variant=self.variant,
                input_type=input_type)

            return interpolator(arg, out=out)

        return self.range.element(nearest, vectorized=True)
293764
def standardize(self, axis=1):
        
        if axis == 1:
            return self.map(lambda x: x / std(x))
        elif axis == 0:
            stdval = self.std().toarray()
            return self.map(lambda x: x / stdval)
        else:
            raise Exception('Axis must be 0 or 1')
191820
def slice(self, tf_tensor, tensor_shape):
    """""""
    tensor_layout = self.tensor_layout(tensor_shape)

    if tensor_layout.is_fully_replicated:
      return self.LaidOutTensor([tf_tensor])
    else:
      slice_shape = self.slice_shape(tensor_shape)
      slice_begins = [
          self.slice_begin(tensor_shape, pnum) for pnum in xrange(self.size)
      ]
      slice_begins_tensor = tf.stack(slice_begins)
      # slice on source device
      selected_slice_begin = tf.gather(slice_begins_tensor, self.pnum_tensor)
      return self.LaidOutTensor(
          [tf.slice(tf_tensor, selected_slice_begin, slice_shape)])
509209
def ix_(selection, shape):
    """"""

    # normalisation
    selection = replace_ellipsis(selection, shape)

    # replace slice and int as these are not supported by numpy.ix_
    selection = [slice_to_range(dim_sel, dim_len) if isinstance(dim_sel, slice)
                 else [dim_sel] if is_integer(dim_sel)
                 else dim_sel
                 for dim_sel, dim_len in zip(selection, shape)]

    # now get numpy to convert to a coordinate selection
    selection = np.ix_(*selection)

    return selection
311011
def get_axis(array, axis, slice_num):
    """"""

    slice_list = [slice(None)] * array.ndim
    slice_list[axis] = slice_num
    slice_data = array[tuple(slice_list)].T  # transpose for proper orientation

    return slice_data
649094
def _ixs(self, i, axis=0):
        
        try:

            # dispatch to the values if we need
            values = self._values
            if isinstance(values, np.ndarray):
                return libindex.get_value_at(values, i)
            else:
                return values[i]
        except IndexError:
            raise
        except Exception:
            if isinstance(i, slice):
                indexer = self.index._convert_slice_indexer(i, kind='iloc')
                return self._get_values(indexer)
            else:
                label = self.index[i]
                if isinstance(label, Index):
                    return self.take(i, axis=axis, convert=True)
                else:
                    return libindex.get_value_at(self, i)