scipy 1.8.0 Pypi GitHub Homepage
Other Docs
AttributesNotesBackRef

Attributes

dtype : dtype

Data type of the array

shape : 2-tuple

Shape of the array

ndim : int

Number of dimensions (this is always 2)

nnz :

Number of nonzero elements

This is an efficient structure for constructing sparse arrays incrementally.

This can be instantiated in several ways:

dok_array(D)

with a dense array, D

dok_array(S)

with a sparse array, S

dok_array((M,N), [dtype])

create the array with initial shape (M,N) dtype is optional, defaulting to dtype='d'

Notes

Sparse arrays can be used in arithmetic operations: they support addition, subtraction, multiplication, division, and array power.

Allows for efficient O(1) access of individual elements. Duplicates are not allowed. Can be efficiently converted to a coo_array once constructed.

Dictionary Of Keys based sparse array.

Examples

>>> import numpy as np
... from scipy.sparse import dok_array
... S = dok_array((5, 5), dtype=np.float32)
... for i in range(5):
...  for j in range(5):
...  S[i, j] = i + j # Update element
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

scipy.sparse._arrays.dok_array

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /scipy/sparse/_arrays.py#80
type: <class 'type'>
Commit: