A small Python utility to tell you what an object is
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file whatis-0.0.1.tar.gz.
File metadata
- Download URL: whatis-0.0.1.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05dac2ba6bf06fe9c2879a0c1878119c7338f1f5072a62dcbd36ee51685ea46c
|
|
| MD5 |
1f51579cd7b058103299ce06afe1b199
|
|
| BLAKE2b-256 |
d5373baf1a7c569eacbfa0c6108ab57b1b40c92f0aa57d23386842b05f56f997
|
File details
Details for the file whatis-0.0.1-py3-none-any.whl.
File metadata
- Download URL: whatis-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6878854817e3c758975d703f3ccc50c031146a6398fc20b16c3e453f2e5575c4
|
|
| MD5 |
5ec1f9cfff452b9a346dc43e09a64662
|
|
| BLAKE2b-256 |
74987a12621c1986c68731dc86a7cc67e92420219aa6d10274452ddb8dc532af
|