setdefault — SciPy v1.15.3 Manual (original) (raw)

scipy.sparse.dok_matrix.

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

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

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