Skip to content

Commit

Permalink
Improve first impression presentation
Browse files Browse the repository at this point in the history
  • Loading branch information
alugowski committed Oct 26, 2023
1 parent 4a912c4 commit fa02f6c
Showing 1 changed file with 31 additions and 29 deletions.
60 changes: 31 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,33 @@ Make every matrix beautiful.
MatRepr formats matrices and tensors to HTML, string, and LaTeX, with Jupyter integration.
See [Jupyter notebook for examples.](https://nbviewer.org/github/alugowski/matrepr/blob/main/doc/demo.ipynb)

```python
from matrepr import mdisplay, mprint
```

`mprint(A)` or `to_str(A)`:
```
<1000×1000, 212345 'float64' elements, coo>
0 1 2 3 4 5 6 7
┌ ┐
0 │ 0.3876 ... │
1 │ 0.5801 0.5085 0.8927 0.629 ... │
2 │ ... │
3 │ 0.7142 ... │
4 │ 0.8631 ... │
5 │ 0.7863 0.1298 0.9918 0.71 0.3444 ... │
6 │ 0.9481 0.9609 ... │
7 │ 0.09361 0.1679 ... │
8 │ 0.4023 ... │
│ : : : : : : : : ... │
└ ┘
```

`mdisplay(A)` or `to_html(A)`:

<img src="doc/images/html.png" width=400 alt="HTML screenshot"/><br>

Supports:
* **SciPy** - sparse matrices and arrays like `csr_matrix` and `coo_array`
* **NumPy** - `ndarray` [(demo)](https://nbviewer.org/github/alugowski/matrepr/blob/main/doc/demo-numpy.ipynb)
* **[PyTorch](https://pytorch.org/docs/stable/sparse.html)** - dense and sparse `torch.Tensor` [(demo)](https://nbviewer.org/github/alugowski/matrepr/blob/main/doc/demo-pytorch.ipynb)
Expand All @@ -31,46 +58,21 @@ Features:
* A `__repr__` monkey patch to format matrices in the Python shell.
* Fast.

## Quick Start

Install:
```shell
pip install matrepr
```

or

```shell
conda install matrepr
```

```python
from matrepr import mdisplay, mprint
```


### String

```
<1000×1000, 212345 'float64' elements, coo>
0 1 2 3 4 5 6 7
┌ ┐
0 │ 0.3876 ... │
1 │ 0.5801 0.5085 0.8927 0.629 ... │
2 │ ... │
3 │ 0.7142 ... │
4 │ 0.8631 ... │
5 │ 0.7863 0.1298 0.9918 0.71 0.3444 ... │
6 │ 0.9481 0.9609 ... │
7 │ 0.09361 0.1679 ... │
8 │ 0.4023 ... │
│ : : : : : : : : ... │
└ ┘
```

`mprint(A)`, `to_str(A)`
or simply `A` with monkey patching as below
## More Examples

### HTML

<img src="doc/images/html.png" width=400 alt="HTML screenshot"/><br>
<img src="doc/images/html-cities.png" width=400 alt="HTML screenshot"/><br>
<img src="doc/images/html-4d.png" width=400 alt="4D NumPy Array"/><br>
<img src="doc/images/html-adjacency.png" width=290 alt="Adjacency Matrix"/><br>
Expand Down

0 comments on commit fa02f6c

Please sign in to comment.