A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.dok_array.html below:

dok_array — SciPy v1.16.1 Manual

scipy.sparse.

dok_array#
class scipy.sparse.dok_array(arg1, shape=None, dtype=None, copy=False, *, maxprint=None)[source]#

Dictionary Of Keys based sparse array.

This is an efficient structure for constructing sparse arrays incrementally.

This can be instantiated in several ways:
dok_array(D)

where D is a 2-D ndarray

dok_array(S)

with another sparse array or matrix S (equivalent to S.todok())

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

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

Attributes:
dtypedtype

Data type of the array

shape2-tuple

Shape of the array

ndimint

Number of dimensions (this is always 2)

nnz

Number of stored values, including explicit zeros.

size

Number of stored values.

T

Transpose.

Methods

Notes

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

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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4