scipy.sparse.dok_array.

setdefault#

dok_array.setdefault(key, default=None, /)[source]#

Insert key with a value of default if key is not in the dictionary.

Parameters:
keyint or tuple of int

The key to look for in the dok_array.

defaultoptional

The value to insert if key is not found. Default is None.

Returns:
scalar

The value for key if key is in the dictionary, else default.