pad
Performs the equivalent of numpy.pad for SparseArray. Note that this function returns a new array instead of a view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array |
SparseArray
|
Sparse array which is to be padded. |
required |
pad_width |
(sequence, array_like, int)
|
Number of values padded to the edges of each axis. ((before_1, after_1), … (before_N, after_N)) unique pad widths for each axis. ((before, after),) yields same before and after pad for each axis. (pad,) or int is a shortcut for before = after = pad width for all axes. |
sequence
|
mode |
str
|
Pads to a constant value which is fill value. Currently only constant mode is implemented |
'constant'
|
constant_values |
int
|
The values to set the padded values for each axis. Default is 0. This must be same as fill value. |
required |
Returns:
| Type | Description |
|---|---|
SparseArray
|
The padded sparse array. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If mode != 'constant' or there are unknown arguments. |
ValueError
|
If constant_values != self.fill_value |
See Also
numpy.pad : NumPy equivalent function
Source code in sparse/numba_backend/_common.py
1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 | |