Skip to main content

Display any Python object in a readable way

Project description

PyTypeSummary

Display any Python object in a readable way, with a single function for everything.

Output is limited so that it fits on the screen, but you can still select what you want to see through expands.

Install

This library is a work in progress. API is unstable and will likely be changed.

To install the latest version (not stable): pip install typesum.

For a dev version, clone this repository, then pip install ..

Some examples

Basic usage:

>>> import typesum as ts

>>> ts.print(1)
1

>>> ts.print("A very long string" * 1000)
"A very ...g string"

If you don't want to print, you can format:

>>> import typesum as ts

>>> ts.format(1)
"1"

>>> ts.format("A very long string" * 1000)
"A very ...g string"

Print multiple objects at once:

>>> import typesum as ts

>>> ts.print("a_big_object", "other_object", another_object="another_object", yet_another_object="foo")
[
  "a_big_object",
  "other_object",
  another_object = "another_object",
  yet_another_object = "foo",
]

Lists:

>>> ts.print([1, 2, 3, 4, 5]*2)
list[1, 2, 3, 4, 5, 1, 2, 3, 4, 5]

>>> ts.print([1, 2, 3, 4, 5]*10)
list(50)

Tuples:

>>> ts.print((1, "string", 2))
tuple[1, "string", 2]

>>> ts.print((1, "string", 2), expand=["type"])
tuple[int(1), "string", int(2)]

Count elements:

>>> ts.print([1,1,2,2,3,3,1,2,3]*10, expand=["aggregate"])
list(90)[90*{int}]

>>> ts.print([1,1,2,2,3,3,1,2]*10, expand=["aggregate", "value"])
list(80)[30*{1}, 30*{2}, 20*{3}]

NumPy arrays:

>>> ts.print(np.array([4, 5, 6]))
ndarray((3,)*{int64})

>>> ts.print(np.array([[1, 2, 3], [4, 5, 6]]))
ndarray((2, 3)*{int64})

Pandas:

>>> ts.print(pd.DataFrame({"a": [1, 2], "b": [3, 4]}))
DataFrame(2*{[a, b]})

>>> ts.print(pd.DataFrame({"a": [1, 2], "b": [3, 4]}).set_index("a"))
DataFrame(a->2*{[b]})

>>> ts.print(pd.DataFrame({"a": [1, 2], "b": [3, 4]}), expand=["type"])
DataFrame(2*{[a: int64, b: int64]})

PyTorch:

>>> ts.print(torch.tensor([[1, 1], [2, 3], [3, -1], [4, 6], [5, 2]]))
tensor[cpu]((5, 2)*{int64})

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

typesum-0.1.0.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

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

typesum-0.1.0-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file typesum-0.1.0.tar.gz.

File metadata

  • Download URL: typesum-0.1.0.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for typesum-0.1.0.tar.gz
Algorithm Hash digest
SHA256 66e49216fa7238846ec65e13d87cbeb4c95b17b38c57828e8455cb8ab10ce21e
MD5 46d3823d62e7dd81b563d5077bf0661f
BLAKE2b-256 6181595a18fba8ab1f29bf3689cdce13c623f5a726e3074276232668eefb4e70

See more details on using hashes here.

File details

Details for the file typesum-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: typesum-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for typesum-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dd239b5f80d1fc0f58110d78f2fec717f7f58ae91e3c963fdd249f4a94320a4d
MD5 7dd1e08a414d6f296c9929128b2133db
BLAKE2b-256 f85e7999a5d1ead17c819353c9d2f516f0f2cbac53e5eb666c95e59b68fa61fb

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