pad
Performs the equivalent of sparse.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
2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 |
|