Skip to main content

A one-function package designed to do one thing.. show you the types!

Project description

Show Me The Types (SMTT)

This is a package designed to provide a single utility: showing you the types!

If you frequently end up handling lists of tuples of tensors, lists of tensors, nested lists and tuples, or other similarly convoluted structures, SMTT might be able to make your life just a bit easier. Instead of thinking about needing len, .shape, .size(), or printing out the structure and parsing the brackets and parens, you can just do tt(data), and get an instant overview of the structure.

from showmethetypes import SMTT
import torch

tt = SMTT()
structure = [(torch.randn(2,3), torch.randn(500, 5, 128)) for _ in range(5)]

tt(structure)
list (5)
    |__tuple
        |__Tensor (dtype: torch.float32)
        |   |  (device: cpu)
        |   |__dim_0 (2)
        |   |__dim_1 (3)
        |__Tensor (dtype: torch.float32)
            |  (device: cpu)
            |__dim_0 (500)
            |__dim_1 (5)
            |__dim_2 (128)

Installation

The package isn't yet available on pip, so a local install is the way.

git clone https://github.com/InfiniteSwerve/ShowMeTheTypes.git
cd ShowMeTheTypes
pip install -e .

Behavior

SMTT will by default display the type for whatever you pass it, and traverse all nested types if the passed object has a __getitem__ method.

The default behavior is to iterate across all subtypes, which means it will print out everything the object contains. Some types, like lists, are usually monomorphic, so SMTT will assume monomorphism and only print out the nested structure in the first item of the list.

SMTT will also infer your current imports and use the specific handlers available for any libraries in your locals().

Coverage

SMTT is quite fresh, and so the current coverage only includes objects that I've needed to work with directly. If you feel sad about any missing types, feel free to raise an issue requesting it, or even make a PR! Creating new handlers for types is quite straightforward.

Testing

You can run the tests with pytest --nbval. Since the core functionality doesn't change, the testing focus is on regression tests. For this we use pytest and nbval, using the cell outputs of jupyter notebooks to make sure the untouched cell outputs haven't changed.

The libraries with any coverage are listed here, and you can find detailed coverage information in handlers.py.

Library Total Coverage
stdlib No
Pytorch No
Numpy No

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

showmethetypes-0.1.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

showmethetypes-0.1-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file showmethetypes-0.1.tar.gz.

File metadata

  • Download URL: showmethetypes-0.1.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for showmethetypes-0.1.tar.gz
Algorithm Hash digest
SHA256 8f19987391d24132f77321d106d95e8bc7256516c03438174b8e1a9c42bf9a47
MD5 5cb54fb89326fb3770dc5755d3317f77
BLAKE2b-256 39e441a20aea84157c133adad4ac67ea0c584e000c570fca24b041977a3017ca

See more details on using hashes here.

File details

Details for the file showmethetypes-0.1-py3-none-any.whl.

File metadata

  • Download URL: showmethetypes-0.1-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for showmethetypes-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 42f89dc783e0d27cafb9d6302105452d5c517e70c51782a9a0b2cdc2a3a00478
MD5 7fbc6a372323eafdbdc78d8565406411
BLAKE2b-256 0ae70d9e89c45367e5e1761d3fda3fc38d1c00c6de5d8c395e0457f77ab3a699

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page