topo :: base :: sheetcoords :: Slice :: Class Slice
[hide private]
[frames] | no frames]

Class Slice

source code


Represents a slice of a SheetCoordinateSystem; i.e., an array specifying the row and column start and end points for a submatrix of the SheetCoordinateSystem.

The slice is created from the supplied bounds by calculating the slice that corresponds most closely to the specified bounds. Therefore, the slice does not necessarily correspond exactly to the specified bounds. The bounds that do exactly correspond to the slice are available via the 'bounds' attribute.

Note that the slice does not respect the bounds of the SheetCoordinateSystem, and that actions such as translate() also do not respect the bounds. To ensure that the slice is within the SheetCoordinateSystem's bounds, use crop_to_sheet().

Instance Methods [hide private]
 
compute_bounds(self, scs) source code
 
submatrix(self, matrix)
Return the submatrix of the given matrix specified by this slice.
source code
 
positionlesscrop(self, x, y, sheet_coord_system)
Return the correct slice for a weights/mask matrix at this ConnectionField's location on the sheet (i.e.
source code
 
positionedcrop(self, x, y, sheet_coord_system)
Offset the bounds_template to this cf's location and store the result in the 'bounds' attribute.
source code
 
translate(self, r, c)
Translate the slice by the specified number of rows and columns.
source code
 
set(self, slice_specification)
Set this slice from some iterable that specifies (r1,r2,c1,c2).
source code
 
shape_on_sheet(self)
Return the shape of the array that this Slice would give on its sheet.
source code
 
crop_to_sheet(self, sheet_coord_system)
Crop the slice to the SheetCoordinateSystem's bounds.
source code

Inherited from numpy.ndarray: __abs__, __add__, __and__, __array__, __array_wrap__, __contains__, __copy__, __deepcopy__, __delitem__, __delslice__, __div__, __divmod__, __eq__, __float__, __floordiv__, __ge__, __getitem__, __getslice__, __gt__, __hex__, __iadd__, __iand__, __idiv__, __ifloordiv__, __ilshift__, __imod__, __imul__, __index__, __int__, __invert__, __ior__, __ipow__, __irshift__, __isub__, __iter__, __itruediv__, __ixor__, __le__, __len__, __long__, __lshift__, __lt__, __mod__, __mul__, __ne__, __neg__, __nonzero__, __oct__, __or__, __pos__, __pow__, __radd__, __rand__, __rdiv__, __rdivmod__, __reduce__, __repr__, __rfloordiv__, __rlshift__, __rmod__, __rmul__, __ror__, __rpow__, __rrshift__, __rshift__, __rsub__, __rtruediv__, __rxor__, __setitem__, __setslice__, __setstate__, __str__, __sub__, __truediv__, __xor__, all, any, argmax, argmin, argsort, astype, byteswap, choose, clip, compress, conj, conjugate, copy, cumprod, cumsum, diagonal, dump, dumps, fill, flatten, getfield, item, itemset, max, mean, min, newbyteorder, nonzero, prod, ptp, put, ravel, repeat, reshape, resize, round, searchsorted, setfield, setflags, sort, squeeze, std, sum, swapaxes, take, tofile, tolist, tostring, trace, transpose, var, view

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Static Methods [hide private]
 
__new__(cls, bounds, sheet_coordinate_system, force_odd=False, min_matrix_radius=1)
staticmethod(function) -> method
source code
 
_createoddslicespec(bounds, scs, min_matrix_radius)
staticmethod(function) -> method
source code
 
_boundsspec2slicespec(boundsspec, scs)
staticmethod(function) -> method
source code
 
_slicespec2boundsspec(slicespec, scs)
staticmethod(function) -> method
source code
Properties [hide private]

Inherited from numpy.ndarray: T, __array_finalize__, __array_interface__, __array_priority__, __array_struct__, base, ctypes, data, dtype, flags, flat, imag, itemsize, nbytes, ndim, real, shape, size, strides

Inherited from object: __class__

Method Details [hide private]

__new__(cls, bounds, sheet_coordinate_system, force_odd=False, min_matrix_radius=1)
Static Method

source code 

staticmethod(function) -> method

Convert a function to be a static method.

A static method does not receive an implicit first argument. To declare a static method, use this idiom:

class C:
def f(arg1, arg2, ...): ... f = staticmethod(f)

It can be called either on the class (e.g. C.f()) or on an instance (e.g. C().f()). The instance is ignored except for its class.

Static methods in Python are similar to those found in Java or C++. For a more advanced concept, see the classmethod builtin.

Overrides: object.__new__

submatrix(self, matrix)

source code 

Return the submatrix of the given matrix specified by this slice.

Equivalent to computing the intersection between the SheetCoordinateSystem's bounds and the bounds, and returning the corresponding submatrix of the given matrix.

The submatrix is just a view into the sheet_matrix; it is not an independent copy.

positionlesscrop(self, x, y, sheet_coord_system)

source code 
Return the correct slice for a weights/mask matrix at this ConnectionField's location on the sheet (i.e. for getting the correct submatrix of the weights or mask in case the unit is near the edge of the sheet).

positionedcrop(self, x, y, sheet_coord_system)

source code 

Offset the bounds_template to this cf's location and store the result in the 'bounds' attribute.

Also stores the input_sheet_slice for access by C.

_createoddslicespec(bounds, scs, min_matrix_radius)
Static Method

source code 

staticmethod(function) -> method

Convert a function to be a static method.

A static method does not receive an implicit first argument. To declare a static method, use this idiom:

class C:
def f(arg1, arg2, ...): ... f = staticmethod(f)

It can be called either on the class (e.g. C.f()) or on an instance (e.g. C().f()). The instance is ignored except for its class.

Static methods in Python are similar to those found in Java or C++. For a more advanced concept, see the classmethod builtin.

_boundsspec2slicespec(boundsspec, scs)
Static Method

source code 

staticmethod(function) -> method

Convert a function to be a static method.

A static method does not receive an implicit first argument. To declare a static method, use this idiom:

class C:
def f(arg1, arg2, ...): ... f = staticmethod(f)

It can be called either on the class (e.g. C.f()) or on an instance (e.g. C().f()). The instance is ignored except for its class.

Static methods in Python are similar to those found in Java or C++. For a more advanced concept, see the classmethod builtin.

_slicespec2boundsspec(slicespec, scs)
Static Method

source code 

staticmethod(function) -> method

Convert a function to be a static method.

A static method does not receive an implicit first argument. To declare a static method, use this idiom:

class C:
def f(arg1, arg2, ...): ... f = staticmethod(f)

It can be called either on the class (e.g. C.f()) or on an instance (e.g. C().f()). The instance is ignored except for its class.

Static methods in Python are similar to those found in Java or C++. For a more advanced concept, see the classmethod builtin.