WhatIs package
Gives a concise summary of any object's structure and avoids accidentally printing a huge object to stdout.
Works with various libraries (NumPy, PyTorch etc.) via duck typing.
Examples
whatis is useful for inspecting large objects quickly:
>> x = list(enumerate(range(7,4129,3)))
>> x
# ... (veeery large output) ...
>> whatis(x)
list len=1374
├ tuple len=2
│ ├ 0: int
│ └ 7: int
│
├ tuple len=2
│ ├ 1: int
│ └ 10: int
│
├ tuple len=2
│ ├ 2: int
│ └ 13: int
│
├ tuple len=2
│ ├ 3: int
│ └ 16: int
│
└ ...
>>
And makes it easy to view the format of objects like this
>>> x = np.ones((5, 5))
>>> out = np.linalg.eig(x)
>>> out
# A lot of information...
(array([5.00000000e+00, 5.65333918e-49, 0.00000000e+00, 0.00000000e+00,
1.73014109e-64]), array([[-4.47213595e-01, 1.13586253e-16, 1.13586253e-16,
1.38161505e-31, -1.11062157e-16],
[-4.47213595e-01, 8.66025404e-01, 8.66025404e-01,
1.05339661e-15, -8.46780726e-01],
[-4.47213595e-01, -2.88675135e-01, -2.88675135e-01,
-2.39769783e-16, 1.11088069e-01],
[-4.47213595e-01, -2.88675135e-01, -2.88675135e-01,
-7.07106781e-01, 3.67846328e-01],
[-4.47213595e-01, -2.88675135e-01, -2.88675135e-01,
7.07106781e-01, 3.67846328e-01]]))
>> whatis(out)
tuple len=2
├ ndarray shape=(5,) dtype=float64
└ ndarray shape=(5, 5) dtype=float64
>>
or this
>> x = torch.randn((103, 75))
>> out = torch.topk(x, 5)
# what's the format of the output again..?
>> out
# ... (very large output) ...
>> whatis(out)
topk len=2
├ Tensor shape=torch.Size([103, 5]) dtype=torch.float32 device=cpu
└ Tensor shape=torch.Size([103, 5]) dtype=torch.int64 device=cpu
>>
Usage
from whatis import whatis
Setup
pip install whatis
Release files for whatis 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| whatis-0.0.1.tar.gz | 6.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| whatis-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.6 kB
Release files / whatis-0.0.1.tar.gz
| Download URL | whatis-0.0.1.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
05dac2ba6bf06fe9c2879a0c1878119c7338f1f5072a62dcbd36ee51685ea46c
|
|
BLAKE2b-256 checksum How to use checksums |
d5373baf1a7c569eacbfa0c6108ab57b1b40c92f0aa57d23386842b05f56f997
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.13
|
Release files / whatis-0.0.1-py3-none-any.whl
| Download URL | whatis-0.0.1-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6878854817e3c758975d703f3ccc50c031146a6398fc20b16c3e453f2e5575c4
|
|
BLAKE2b-256 checksum How to use checksums |
74987a12621c1986c68731dc86a7cc67e92420219aa6d10274452ddb8dc532af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.13
|