Pretty printer for matrices and column vectors.
Project description
Struggling to tell your rows from your columns?
prettymatrix creates human-friendly string representations of your numpy matrices and vectors, just like you’re used to.
Installation
Available through pip:
pip install prettymatrix
Examples
Stringify a single matrix
import numpy as np import prettymatrix M = np.array([['1', '22'], ['333', '4444']]) print(prettymatrix.matrix_to_string(M)) # => # ┌ ┐ # │ 1 22 │ # │ 333 4444 │ # └ ┘ # # We condense large matrices to a readable size N = prettymatrix.matrix_to_string(np.full((1000,1000), '0')) print(prettymatrix.matrix_to_string(N)) # => # ┌ ┐ # │ 0 0 0 … … … 0 0 0 │ # │ 0 0 0 … … … 0 0 0 │ # │ 0 0 0 … … … 0 0 0 │ # │ … … … … … … … … … │ # │ … … … … … … … … … │ # │ … … … … … … … … … │ # │ 0 0 0 … … … 0 0 0 │ # │ 0 0 0 … … … 0 0 0 │ # │ 0 0 0 … … … 0 0 0 │ # └ ┘ #
Annotate your matrix with a name:
import numpy as np import prettymatrix M = np.array([['0'], ['0']]) print(prettymatrix.matrix_to_string(M, name='M_x_y')) # => # ┌ ┐ # │ 0 │ # │ 0 │ # └ ┘ # M_x_y #
Or its dimensions:
import numpy as np import prettymatrix M = np.array([['0'], ['0']]) print(prettymatrix.matrix_to_string(M, include_dimensions=True)) # => # ┌ ┐ # │ 0 │ # │ 0 │ # └ ┘ # (2x1) #
Stringify a multiple matrices in a row
import numpy as np import prettymatrix M = np.array([['1', '22'], ['333', '4444']]) print(prettymatrix.matrices_to_string(M, M)) # => # ┌ ┐ ┌ ┐ # │ 1 22 │ │ 1 22 │ # │ 333 4444 │ │ 333 4444 │ # └ ┘ └ ┘ #
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
prettymatrix-0.1.2.tar.gz
(1.9 kB
view details)
File details
Details for the file prettymatrix-0.1.2.tar.gz.
File metadata
- Download URL: prettymatrix-0.1.2.tar.gz
- Upload date:
- Size: 1.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34b79df55d39cef33893ee49ce981a916cef98b8a0ad656da8b7d56f96f65549
|
|
| MD5 |
764b35919dd3958ea0fcd55423d813d7
|
|
| BLAKE2b-256 |
d47f068d0ce909f14c039a7a80a7b21ac52c56890cefe8eb7402743ab4fb7537
|