neulab/docprompting-conala huggingface dataset:
skimage.util.apply_parallel(function, array, chunks=None, depth=0, mode=None, extra_arguments=(), extra_keywords={}, *, dtype=None, multichannel=False, compute=None) [source]
 
Map a function in parallel across an array. Split an array into possibly overlapping chunks of a given depth and boundary type, call the given function in parallel on the chunks, combine the chunks and return the resulting array.  Parameters 
 
functionfunction 

Function to be mapped which takes an array as an argument.  
arraynumpy array or dask array 

Array which the function will be applied to.  
chunksint, tuple, or tuple of tuples, optional 

A single integer is interpreted as the length of one side of a square chunk that should be tiled across the array. One tuple of length array.ndim represents the shape of a chunk, and it is tiled across the array. A list of tuples of length ndim, where each sub-tuple is a sequence of chunk sizes along the corresponding dimension. If None, the array is broken up into chunks based on the number of available cpus. More information about chunks is in the documentation here.  
depthint, optional 

Integer equal to the depth of the added boundary cells. Defaults to zero.  
mode{‘reflect’, ‘symmetric’, ‘periodic’, ‘wrap’, ‘nearest’, ‘edge’}, optional 

type of external boundary padding.  
extra_argumentstuple, optional 

Tuple of arguments to be passed to the function.  
extra_keywordsdictionary, optional 

Dictionary of keyword arguments to be passed to the function.  
dtypedata-type or None, optional 

The data-type of the function output. If None, Dask will attempt to infer this by calling the function on data of shape (1,) * ndim. For functions expecting RGB or multichannel data this may be problematic. In such cases, the user should manually specify this dtype argument instead.  New in version 0.18: dtype was added in 0.18.   
multichannelbool, optional 

If chunks is None and multichannel is True, this function will keep only a single chunk along the channels axis. When depth is specified as a scalar value, that depth will be applied only to the non-channels axes (a depth of 0 will be used along the channels axis). If the user manually specified both chunks and a depth tuple, then this argument will have no effect.  New in version 0.18: multichannel was added in 0.18.   
computebool, optional 

If True, compute eagerly returning a NumPy Array. If False, compute lazily returning a Dask Array. If None (default), compute based on array type provided (eagerly for NumPy Arrays and lazily for Dask Arrays).    Returns 
 
outndarray or dask Array 

Returns the result of the applying the operation. Type is dependent on the compute argument.     Notes Numpy edge modes ‘symmetric’, ‘wrap’, and ‘edge’ are converted to the equivalent dask boundary modes ‘reflect’, ‘periodic’ and ‘nearest’, respectively. Setting compute=False can be useful for chaining later operations. For example region selection to preview a result or storing large data to disk instead of loading in memory.
skimage.util.compare_images(image1, image2, method='diff', *, n_tiles=(8, 8)) [source]
 
Return an image showing the differences between two images.  New in version 0.16.   Parameters 
 
image1, image22-D array 

Images to process, must be of the same shape.  
methodstring, optional 

Method used for the comparison. Valid values are {‘diff’, ‘blend’, ‘checkerboard’}. Details are provided in the note section.  
n_tilestuple, optional 

Used only for the checkerboard method. Specifies the number of tiles (row, column) to divide the image.    Returns 
 
comparison2-D array 

Image showing the differences.     Notes 'diff' computes the absolute difference between the two images. 'blend' computes the mean value. 'checkerboard' makes tiles of dimension n_tiles that display alternatively the first and the second image.
skimage.util.crop(ar, crop_width, copy=False, order='K') [source]
 
Crop array ar by crop_width along each dimension.  Parameters 
 
ararray-like of rank N 

Input array.  
crop_width{sequence, int} 

Number of values to remove from the edges of each axis. ((before_1, after_1), … (before_N, after_N)) specifies unique crop widths at the start and end of each axis. ((before, after),) or (before, after) specifies a fixed start and end crop for every axis. (n,) or n for integer n is a shortcut for before = after = n for all axes.  
copybool, optional 

If True, ensure the returned array is a contiguous copy. Normally, a crop operation will return a discontiguous view of the underlying input array.  
order{‘C’, ‘F’, ‘A’, ‘K’}, optional 

If copy==True, control the memory layout of the copy. See np.copy.    Returns 
 
croppedarray 

The cropped array. If copy=False (default), this is a sliced view of the input array.
skimage.util.dtype_limits(image, clip_negative=False) [source]
 
Return intensity limits, i.e. (min, max) tuple, of the image’s dtype.  Parameters 
 
imagendarray 

Input image.  
clip_negativebool, optional 

If True, clip the negative range (i.e. return 0 for min intensity) even if the image dtype allows negative values.    Returns 
 
imin, imaxtuple 

Lower and upper intensity limits.
skimage.util.img_as_bool(image, force_copy=False) [source]
 
Convert an image to boolean format.  Parameters 
 
imagendarray 

Input image.  
force_copybool, optional 

Force a copy of the data, irrespective of its current dtype.    Returns 
 
outndarray of bool (bool_) 

Output image.     Notes The upper half of the input dtype’s positive range is True, and the lower half is False. All negative values (if present) are False.
skimage.util.img_as_float(image, force_copy=False) [source]
 
Convert an image to floating point format. This function is similar to img_as_float64, but will not convert lower-precision floating point arrays to float64.  Parameters 
 
imagendarray 

Input image.  
force_copybool, optional 

Force a copy of the data, irrespective of its current dtype.    Returns 
 
outndarray of float 

Output image.     Notes The range of a floating point image is [0.0, 1.0] or [-1.0, 1.0] when converting from unsigned or signed datatypes, respectively. If the input image has a float type, intensity values are not modified and can be outside the ranges [0.0, 1.0] or [-1.0, 1.0].
skimage.util.img_as_float32(image, force_copy=False) [source]
 
Convert an image to single-precision (32-bit) floating point format.  Parameters 
 
imagendarray 

Input image.  
force_copybool, optional 

Force a copy of the data, irrespective of its current dtype.    Returns 
 
outndarray of float32 

Output image.     Notes The range of a floating point image is [0.0, 1.0] or [-1.0, 1.0] when converting from unsigned or signed datatypes, respectively. If the input image has a float type, intensity values are not modified and can be outside the ranges [0.0, 1.0] or [-1.0, 1.0].
skimage.util.img_as_float64(image, force_copy=False) [source]
 
Convert an image to double-precision (64-bit) floating point format.  Parameters 
 
imagendarray 

Input image.  
force_copybool, optional 

Force a copy of the data, irrespective of its current dtype.    Returns 
 
outndarray of float64 

Output image.     Notes The range of a floating point image is [0.0, 1.0] or [-1.0, 1.0] when converting from unsigned or signed datatypes, respectively. If the input image has a float type, intensity values are not modified and can be outside the ranges [0.0, 1.0] or [-1.0, 1.0].
skimage.util.img_as_int(image, force_copy=False) [source]
 
Convert an image to 16-bit signed integer format.  Parameters 
 
imagendarray 

Input image.  
force_copybool, optional 

Force a copy of the data, irrespective of its current dtype.    Returns 
 
outndarray of int16 

Output image.     Notes The values are scaled between -32768 and 32767. If the input data-type is positive-only (e.g., uint8), then the output image will still only have positive values.
skimage.util.img_as_ubyte(image, force_copy=False) [source]
 
Convert an image to 8-bit unsigned integer format.  Parameters 
 
imagendarray 

Input image.  
force_copybool, optional 

Force a copy of the data, irrespective of its current dtype.    Returns 
 
outndarray of ubyte (uint8) 

Output image.     Notes Negative input values will be clipped. Positive values are scaled between 0 and 255.
skimage.util.img_as_uint(image, force_copy=False) [source]
 
Convert an image to 16-bit unsigned integer format.  Parameters 
 
imagendarray 

Input image.  
force_copybool, optional 

Force a copy of the data, irrespective of its current dtype.    Returns 
 
outndarray of uint16 

Output image.     Notes Negative input values will be clipped. Positive values are scaled between 0 and 65535.
skimage.util.invert(image, signed_float=False) [source]
 
Invert an image. Invert the intensity range of the input image, so that the dtype maximum is now the dtype minimum, and vice-versa. This operation is slightly different depending on the input dtype:  unsigned integers: subtract the image from the dtype maximum signed integers: subtract the image from -1 (see Notes) floats: subtract the image from 1 (if signed_float is False, so we assume the image is unsigned), or from 0 (if signed_float is True).  See the examples for clarification.  Parameters 
 
imagendarray 

Input image.  
signed_floatbool, optional 

If True and the image is of type float, the range is assumed to be [-1, 1]. If False and the image is of type float, the range is assumed to be [0, 1].    Returns 
 
invertedndarray 

Inverted image.     Notes Ideally, for signed integers we would simply multiply by -1. However, signed integer ranges are asymmetric. For example, for np.int8, the range of possible values is [-128, 127], so that -128 * -1 equals -128! By subtracting from -1, we correctly map the maximum dtype value to the minimum. Examples >>> img = np.array([[100,  0, 200],
...                 [  0, 50,   0],
...                 [ 30,  0, 255]], np.uint8)
>>> invert(img)
array([[155, 255,  55],
       [255, 205, 255],
       [225, 255,   0]], dtype=uint8)
>>> img2 = np.array([[ -2, 0, -128],
...                  [127, 0,    5]], np.int8)
>>> invert(img2)
array([[   1,   -1,  127],
       [-128,   -1,   -6]], dtype=int8)
>>> img3 = np.array([[ 0., 1., 0.5, 0.75]])
>>> invert(img3)
array([[1.  , 0.  , 0.5 , 0.25]])
>>> img4 = np.array([[ 0., 1., -1., -0.25]])
>>> invert(img4, signed_float=True)
array([[-0.  , -1.  ,  1.  ,  0.25]])
skimage.util.map_array(input_arr, input_vals, output_vals, out=None) [source]
 
Map values from input array from input_vals to output_vals.  Parameters 
 
input_arrarray of int, shape (M[, N][, P][, …]) 

The input label image.  
input_valsarray of int, shape (N,) 

The values to map from.  
output_valsarray, shape (N,) 

The values to map to.  out: array, same shape as `input_arr`

The output array. Will be created if not provided. It should have the same dtype as output_vals.    Returns 
 
outarray, same shape as input_arr 

The array of mapped values.
skimage.util.montage(arr_in, fill='mean', rescale_intensity=False, grid_shape=None, padding_width=0, multichannel=False) [source]
 
Create a montage of several single- or multichannel images. Create a rectangular montage from an input array representing an ensemble of equally shaped single- (gray) or multichannel (color) images. For example, montage(arr_in) called with the following arr_in  
1 2 3   will return  
1 2  
3 
      where the ‘*’ patch will be determined by the fill parameter.  Parameters 
 
arr_in(K, M, N[, C]) ndarray 

An array representing an ensemble of K images of equal shape.  
fillfloat or array-like of floats or ‘mean’, optional 

Value to fill the padding areas and/or the extra tiles in the output array. Has to be float for single channel collections. For multichannel collections has to be an array-like of shape of number of channels. If mean, uses the mean value over all images.  
rescale_intensitybool, optional 

Whether to rescale the intensity of each image to [0, 1].  
grid_shapetuple, optional 

The desired grid shape for the montage (ntiles_row, ntiles_column). The default aspect ratio is square.  
padding_widthint, optional 

The size of the spacing between the tiles and between the tiles and the borders. If non-zero, makes the boundaries of individual images easier to perceive.  
multichannelboolean, optional 

If True, the last arr_in dimension is threated as a color channel, otherwise as spatial.    Returns 
 
arr_out(K*(M+p)+p, K*(N+p)+p[, C]) ndarray 

Output array with input images glued together (including padding p).     Examples >>> import numpy as np
>>> from skimage.util import montage
>>> arr_in = np.arange(3 * 2 * 2).reshape(3, 2, 2)
>>> arr_in  
array([[[ 0,  1],
        [ 2,  3]],
       [[ 4,  5],
        [ 6,  7]],
       [[ 8,  9],
        [10, 11]]])
>>> arr_out = montage(arr_in)
>>> arr_out.shape
(4, 4)
>>> arr_out
array([[ 0,  1,  4,  5],
       [ 2,  3,  6,  7],
       [ 8,  9,  5,  5],
       [10, 11,  5,  5]])
>>> arr_in.mean()
5.5
>>> arr_out_nonsquare = montage(arr_in, grid_shape=(1, 3))
>>> arr_out_nonsquare
array([[ 0,  1,  4,  5,  8,  9],
       [ 2,  3,  6,  7, 10, 11]])
>>> arr_out_nonsquare.shape
(2, 6)
skimage.util.regular_grid(ar_shape, n_points) [source]
 
Find n_points regularly spaced along ar_shape. The returned points (as slices) should be as close to cubically-spaced as possible. Essentially, the points are spaced by the Nth root of the input array size, where N is the number of dimensions. However, if an array dimension cannot fit a full step size, it is “discarded”, and the computation is done for only the remaining dimensions.  Parameters 
 
ar_shapearray-like of ints 

The shape of the space embedding the grid. len(ar_shape) is the number of dimensions.  
n_pointsint 

The (approximate) number of points to embed in the space.    Returns 
 
slicestuple of slice objects 

A slice along each dimension of ar_shape, such that the intersection of all the slices give the coordinates of regularly spaced points.  Changed in version 0.14.1: In scikit-image 0.14.1 and 0.15, the return type was changed from a list to a tuple to ensure compatibility with Numpy 1.15 and higher. If your code requires the returned result to be a list, you may convert the output of this function to a list with: >>> result = list(regular_grid(ar_shape=(3, 20, 40), n_points=8))
      Examples >>> ar = np.zeros((20, 40))
>>> g = regular_grid(ar.shape, 8)
>>> g
(slice(5, None, 10), slice(5, None, 10))
>>> ar[g] = 1
>>> ar.sum()
8.0
>>> ar = np.zeros((20, 40))
>>> g = regular_grid(ar.shape, 32)
>>> g
(slice(2, None, 5), slice(2, None, 5))
>>> ar[g] = 1
>>> ar.sum()
32.0
>>> ar = np.zeros((3, 20, 40))
>>> g = regular_grid(ar.shape, 8)
>>> g
(slice(1, None, 3), slice(5, None, 10), slice(5, None, 10))
>>> ar[g] = 1
>>> ar.sum()
8.0
skimage.util.regular_seeds(ar_shape, n_points, dtype=<class 'int'>) [source]
 
Return an image with ~`n_points` regularly-spaced nonzero pixels.  Parameters 
 
ar_shapetuple of int 

The shape of the desired output image.  
n_pointsint 

The desired number of nonzero points.  
dtypenumpy data type, optional 

The desired data type of the output.    Returns 
 
seed_imgarray of int or bool 

The desired image.     Examples >>> regular_seeds((5, 5), 4)
array([[0, 0, 0, 0, 0],
       [0, 1, 0, 2, 0],
       [0, 0, 0, 0, 0],
       [0, 3, 0, 4, 0],
       [0, 0, 0, 0, 0]])
skimage.util.unique_rows(ar) [source]
 
Remove repeated rows from a 2D array. In particular, if given an array of coordinates of shape (Npoints, Ndim), it will remove repeated points.  Parameters 
 
ar2-D ndarray 

The input array.    Returns 
 
ar_out2-D ndarray 

A copy of the input array with repeated rows removed.    Raises 
 
ValueErrorif ar is not two-dimensional. 
   Notes The function will generate a copy of ar if it is not C-contiguous, which will negatively affect performance for large input arrays. Examples >>> ar = np.array([[1, 0, 1],
...                [0, 1, 0],
...                [1, 0, 1]], np.uint8)
>>> unique_rows(ar)
array([[0, 1, 0],
       [1, 0, 1]], dtype=uint8)
skimage.util.view_as_blocks(arr_in, block_shape) [source]
 
Block view of the input n-dimensional array (using re-striding). Blocks are non-overlapping views of the input array.  Parameters 
 
arr_inndarray 

N-d input array.  
block_shapetuple 

The shape of the block. Each dimension must divide evenly into the corresponding dimensions of arr_in.    Returns 
 
arr_outndarray 

Block view of the input array.     Examples >>> import numpy as np
>>> from skimage.util.shape import view_as_blocks
>>> A = np.arange(4*4).reshape(4,4)
>>> A
array([[ 0,  1,  2,  3],
       [ 4,  5,  6,  7],
       [ 8,  9, 10, 11],
       [12, 13, 14, 15]])
>>> B = view_as_blocks(A, block_shape=(2, 2))
>>> B[0, 0]
array([[0, 1],
       [4, 5]])
>>> B[0, 1]
array([[2, 3],
       [6, 7]])
>>> B[1, 0, 1, 1]
13
 >>> A = np.arange(4*4*6).reshape(4,4,6)
>>> A  
array([[[ 0,  1,  2,  3,  4,  5],
        [ 6,  7,  8,  9, 10, 11],
        [12, 13, 14, 15, 16, 17],
        [18, 19, 20, 21, 22, 23]],
       [[24, 25, 26, 27, 28, 29],
        [30, 31, 32, 33, 34, 35],
        [36, 37, 38, 39, 40, 41],
        [42, 43, 44, 45, 46, 47]],
       [[48, 49, 50, 51, 52, 53],
        [54, 55, 56, 57, 58, 59],
        [60, 61, 62, 63, 64, 65],
        [66, 67, 68, 69, 70, 71]],
       [[72, 73, 74, 75, 76, 77],
        [78, 79, 80, 81, 82, 83],
        [84, 85, 86, 87, 88, 89],
        [90, 91, 92, 93, 94, 95]]])
>>> B = view_as_blocks(A, block_shape=(1, 2, 2))
>>> B.shape
(4, 2, 3, 1, 2, 2)
>>> B[2:, 0, 2]  
array([[[[52, 53],
         [58, 59]]],
       [[[76, 77],
         [82, 83]]]])
skimage.util.view_as_windows(arr_in, window_shape, step=1) [source]
 
Rolling window view of the input n-dimensional array. Windows are overlapping views of the input array, with adjacent windows shifted by a single row or column (or an index of a higher dimension).  Parameters 
 
arr_inndarray 

N-d input array.  
window_shapeinteger or tuple of length arr_in.ndim 

Defines the shape of the elementary n-dimensional orthotope (better know as hyperrectangle [1]) of the rolling window view. If an integer is given, the shape will be a hypercube of sidelength given by its value.  
stepinteger or tuple of length arr_in.ndim 

Indicates step size at which extraction shall be performed. If integer is given, then the step is uniform in all dimensions.    Returns 
 
arr_outndarray 

(rolling) window view of the input array.     Notes One should be very careful with rolling views when it comes to memory usage. Indeed, although a ‘view’ has the same memory footprint as its base array, the actual array that emerges when this ‘view’ is used in a computation is generally a (much) larger array than the original, especially for 2-dimensional arrays and above. For example, let us consider a 3 dimensional array of size (100, 100, 100) of float64. This array takes about 8*100**3 Bytes for storage which is just 8 MB. If one decides to build a rolling view on this array with a window of (3, 3, 3) the hypothetical size of the rolling view (if one was to reshape the view for example) would be 8*(100-3+1)**3*3**3 which is about 203 MB! The scaling becomes even worse as the dimension of the input array becomes larger. References  
1  
https://en.wikipedia.org/wiki/Hyperrectangle   Examples >>> import numpy as np
>>> from skimage.util.shape import view_as_windows
>>> A = np.arange(4*4).reshape(4,4)
>>> A
array([[ 0,  1,  2,  3],
       [ 4,  5,  6,  7],
       [ 8,  9, 10, 11],
       [12, 13, 14, 15]])
>>> window_shape = (2, 2)
>>> B = view_as_windows(A, window_shape)
>>> B[0, 0]
array([[0, 1],
       [4, 5]])
>>> B[0, 1]
array([[1, 2],
       [5, 6]])
 >>> A = np.arange(10)
>>> A
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> window_shape = (3,)
>>> B = view_as_windows(A, window_shape)
>>> B.shape
(8, 3)
>>> B
array([[0, 1, 2],
       [1, 2, 3],
       [2, 3, 4],
       [3, 4, 5],
       [4, 5, 6],
       [5, 6, 7],
       [6, 7, 8],
       [7, 8, 9]])
 >>> A = np.arange(5*4).reshape(5, 4)
>>> A
array([[ 0,  1,  2,  3],
       [ 4,  5,  6,  7],
       [ 8,  9, 10, 11],
       [12, 13, 14, 15],
       [16, 17, 18, 19]])
>>> window_shape = (4, 3)
>>> B = view_as_windows(A, window_shape)
>>> B.shape
(2, 2, 4, 3)
>>> B  
array([[[[ 0,  1,  2],
         [ 4,  5,  6],
         [ 8,  9, 10],
         [12, 13, 14]],
        [[ 1,  2,  3],
         [ 5,  6,  7],
         [ 9, 10, 11],
         [13, 14, 15]]],
       [[[ 4,  5,  6],
         [ 8,  9, 10],
         [12, 13, 14],
         [16, 17, 18]],
        [[ 5,  6,  7],
         [ 9, 10, 11],
         [13, 14, 15],
         [17, 18, 19]]]])
class skimage.viewer.canvastools.LineTool(manager, on_move=None, on_release=None, on_enter=None, maxdist=10, line_props=None, handle_props=None, **kwargs) [source]
 
Bases: skimage.viewer.canvastools.base.CanvasToolBase Widget for line selection in a plot.  Parameters 
 
managerViewer or PlotPlugin. 

Skimage viewer or plot plugin object.  
on_movefunction 

Function called whenever a control handle is moved. This function must accept the end points of line as the only argument.  
on_releasefunction 

Function called whenever the control handle is released.  
on_enterfunction 

Function called whenever the “enter” key is pressed.  
maxdistfloat 

Maximum pixel distance allowed when selecting control handle.  
line_propsdict 

Properties for matplotlib.lines.Line2D.  
handle_propsdict 

Marker properties for the handles (also see matplotlib.lines.Line2D).    Attributes 
 
end_points2D array 

End points of line ((x1, y1), (x2, y2)).      
__init__(manager, on_move=None, on_release=None, on_enter=None, maxdist=10, line_props=None, handle_props=None, **kwargs) [source]
 
Initialize self. See help(type(self)) for accurate signature. 
  
property end_points 
  
property geometry  
Geometry information that gets passed to callback functions. 
  
hit_test(event) [source]

  
on_mouse_press(event) [source]

  
on_mouse_release(event) [source]

  
on_move(event) [source]

  
update(x=None, y=None) [source]
__init__(manager, on_move=None, on_release=None, on_enter=None, maxdist=10, line_props=None, handle_props=None, **kwargs) [source]
 
Initialize self. See help(type(self)) for accurate signature.
class skimage.viewer.canvastools.PaintTool(manager, overlay_shape, radius=5, alpha=0.3, on_move=None, on_release=None, on_enter=None, rect_props=None) [source]
 
Bases: skimage.viewer.canvastools.base.CanvasToolBase Widget for painting on top of a plot.  Parameters 
 
managerViewer or PlotPlugin. 

Skimage viewer or plot plugin object.  
overlay_shapeshape tuple 

2D shape tuple used to initialize overlay image.  
radiusint 

The size of the paint cursor.  
alphafloat (between [0, 1]) 

Opacity of overlay.  
on_movefunction 

Function called whenever a control handle is moved. This function must accept the end points of line as the only argument.  
on_releasefunction 

Function called whenever the control handle is released.  
on_enterfunction 

Function called whenever the “enter” key is pressed.  
rect_propsdict 

Properties for matplotlib.patches.Rectangle. This class redefines defaults in matplotlib.widgets.RectangleSelector.     Examples >>> from skimage.data import camera
>>> import matplotlib.pyplot as plt
>>> from skimage.viewer.canvastools import PaintTool
>>> import numpy as np
 >>> img = camera() 
 >>> ax = plt.subplot(111) 
>>> plt.imshow(img, cmap=plt.cm.gray) 
>>> p = PaintTool(ax,np.shape(img[:-1]),10,0.2) 
>>> plt.show() 
 >>> mask = p.overlay 
>>> plt.imshow(mask,cmap=plt.cm.gray) 
>>> plt.show() 
  Attributes 
 
overlayarray 

Overlay of painted labels displayed on top of image.  
labelint 

Current paint color.      
__init__(manager, overlay_shape, radius=5, alpha=0.3, on_move=None, on_release=None, on_enter=None, rect_props=None) [source]
 
Initialize self. See help(type(self)) for accurate signature. 
  
property geometry  
Geometry information that gets passed to callback functions. 
  
property label 
  
on_key_press(event) [source]

  
on_mouse_press(event) [source]

  
on_mouse_release(event) [source]

  
on_move(event) [source]

  
property overlay 
  
property radius 
  
property shape 
  
update_cursor(x, y) [source]

  
update_overlay(x, y) [source]