Demonstrate:
With rendering:
import sparse
# so matrepr can be imported from the source tree.
import sys
sys.path.insert(0, '..')
from matrepr import mdisplay
import numpy
numpy.random.seed(1234)
A = sparse.random((100, 100), density=0.21234)
# v = sparse.COO([0, 1, 2, 3, 99], data=[1000, 1001, 1002, 1003, 1099], shape=(100,))
v = sparse.random((1000,), density=0.5)
# T = sparse.COO(coords=[[0, 1], [3, 2], [1, 3]], data=[111, 222], shape=(5, 5, 5))
T = sparse.random((1000, 100, 100), density=0.21234)
A
Format | coo |
---|---|
Data Type | float64 |
Shape | (100, 100) |
nnz | 2123 |
Density | 0.2123 |
Read-only | True |
Size | 49.8K |
Storage ratio | 0.6 |
v
Format | coo |
---|---|
Data Type | float64 |
Shape | (1000,) |
nnz | 500 |
Density | 0.5 |
Read-only | True |
Size | 7.8K |
Storage ratio | 1.0 |
T
Format | coo |
---|---|
Data Type | float64 |
Shape | (1000, 100, 100) |
nnz | 2123400 |
Density | 0.21234 |
Read-only | True |
Size | 64.8M |
Storage ratio | 0.8 |
%load_ext matrepr
A
0 | 1 | 2 | 3 | 4 | 5 | 6 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 0.4977 | ⋯ | 0.4427 | ||||||||||||
1 | ⋯ | 0.8135 | 0.6466 | ||||||||||||
2 | 0.04743 | 0.995 | ⋯ | 0.03235 | |||||||||||
3 | 0.3282 | ⋯ | 0.01163 | 0.07154 | |||||||||||
4 | ⋯ | 0.1318 | |||||||||||||
⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋱ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | |
95 | 0.3315 | ⋯ | 0.7708 | 0.004416 | 0.9238 | ||||||||||
96 | 0.9455 | 0.5961 | ⋯ | 0.237 | 0.6584 | ||||||||||
97 | ⋯ | ||||||||||||||
98 | 0.972 | 0.462 | 0.3726 | ⋯ | 0.3856 | ||||||||||
99 | 0.8263 | ⋯ | 0.01302 |
v
0 | 1 | 2 | 3 | 4 | 5 | 6 | 993 | 994 | 995 | 996 | 997 | 998 | 999 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0.9873 | 0.9495 | 0.7522 | ⋯ | 0.9818 | 0.2377 | 0.9387 |
T
0 | 1 | 2 | val | |
---|---|---|---|---|
0 | 0 | 0 | 4 | 0.8811 |
1 | 0 | 0 | 10 | 0.2228 |
2 | 0 | 0 | 11 | 0.5559 |
3 | 0 | 0 | 21 | 0.5681 |
4 | 0 | 0 | 25 | 0.5452 |
⋮ | ⋮ | ⋮ | ⋮ | |
2123395 | 999 | 99 | 77 | 0.2487 |
2123396 | 999 | 99 | 82 | 0.7877 |
2123397 | 999 | 99 | 84 | 0.4994 |
2123398 | 999 | 99 | 88 | 0.3997 |
2123399 | 999 | 99 | 93 | 0.7297 |
mdisplay(A, "latex")
mdisplay(v, "latex")
mdisplay(T, "latex")
mdisplay(A, "str")
<100×100, 2123 'float64' elements, coo, fill_value=0.0, read-only, 49.8KiB> 0 1 2 3 4 96 97 98 99 ┌ ┐ 0 │ 0.4977 ... │ 1 │ ... 0.6466 │ 2 │ 0.04743 ... 0.03235 │ 3 │ ... 0.07154 │ 4 │ ... 0.1318 │ │ : : : : : ... : : : : │ 95 │ ... 0.9238 │ 96 │ 0.9455 0.9514 ... │ 97 │ ... │ 98 │ 0.972 0.3444 ... 0.3856 │ 99 │ ... 0.01302 │ └ ┘
mdisplay(v, "str")
<length=1000, 500 'float64' elements, coo, fill_value=0.0, read-only, 7.8KiB> 0 1 2 3 4 5 995 996 997 998 999 [ 0.9873 ... 0.9818 0.2377 0.9387]
mdisplay(v, "str", indices=False, title=False)
[, 0.9873, , , , 0.9495, 0.7522, , ..., 0.1255, , , , 0.9818, 0.2377, , 0.9387]
mdisplay(T, "str")
<shape=(1000,100,100), 2123400 'float64' elements, coo, fill_value=0.0, read-only, 64.8MiB> 0 1 2 val 0 ( 0, 0, 4, 0.8811) 1 ( 0, 0, 10, 0.2228) 2 ( 0, 0, 11, 0.5559) 3 ( 0, 0, 21, 0.5681) 4 ( 0, 0, 25, 0.5452) ( :, :, :, : ) 2123395 (999, 99, 77, 0.2487) 2123396 (999, 99, 82, 0.7877) 2123397 (999, 99, 84, 0.4994) 2123398 (999, 99, 88, 0.3997) 2123399 (999, 99, 93, 0.7297)
import matrepr
matrepr.params.max_rows = 10
matrepr.params.max_cols = 7
matrepr.params.num_after_dots = 0
matrepr.params.indices = False
A
0.4977 | ⋯ | |||||
⋯ | ||||||
0.04743 | 0.995 | ⋯ | ||||
0.3282 | ⋯ | |||||
⋯ | ||||||
0.4119 | ⋯ | |||||
0.9375 | 0.6134 | 0.6993 | ⋯ | |||
0.6578 | ⋯ | |||||
0.05845 | ⋯ | |||||
⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋱ |
v
0.9873 | 0.9495 | ⋯ |
T
0 | 0 | 4 | 0.8811 |
0 | 0 | 10 | 0.2228 |
0 | 0 | 11 | 0.5559 |
0 | 0 | 21 | 0.5681 |
0 | 0 | 25 | 0.5452 |
0 | 0 | 37 | 0.4053 |
0 | 0 | 38 | 0.8414 |
0 | 0 | 46 | 0.638 |
0 | 0 | 48 | 0.9332 |
⋮ | ⋮ | ⋮ | ⋮ |