Skip to main content

aprint

A Python print package for those who don't care the actual elements of array-like data (e.g. numpy.array, torch.tensor) within a complex data structure.

Background

By default, print will display the actual elements in array-like data, such as numpy.array or torch.tensor, which is not very friendly for those who don't care about the actual elements. Inspired by the leading scientific computing language Julia, this package will print the type and shape of the data structure, as well as the type and shape of the elements within the data structure.

Installation

pip install aprint

For the latest version, you can install from github:

pip install git+https://github.com/huangyxi/aprint.git

Usage

>>> import numpy as np
>>> import torch
>>> from aprint import aprint

>>> aprint(np.array([1, 2, 3]))
int64[3] numpy.ndarray

>>> aprint({'a': torch.zeros(16, 32).cuda(), 2: [np.array([1, 2]), (torch.zeros(2).to_sparse(), torch.zeros(2,3).to_sparse_csr(), torch.zeros(2,3,4).to_sparse_csc()), {'5', 6, 7.}]}, indent_str='| ')
{ # dict with len=2
| 'a': float32[16×32] torch.Tensor at 'cuda:0' with grad=False,
| 2: [ # list with len=3
| | int64[2] numpy.ndarray,
| | ( # tuple with len=3
| | | float32[2] torch.Tensor at 'cpu' with layout='COO', grad=False,
| | | float32[2×3] torch.Tensor at 'cpu' with layout='CSR', grad=False,
| | | float32[2×3×4] torch.Tensor at 'cpu' with layout='CSC', grad=False,
| | ),
| | { # set with len=3
| | | '5',
| | | 6,
| | | 7.0,
| | },
| ],
}

>>> aprint([1, [2, [3, [4, [5]]]]], max_depth=3, indent_str="⋮ ") # default max_depth=5
[ # list with len=2
⋮ 1,
⋮ [ # list with len=2
⋮ ⋮ 2,
⋮ ⋮ [ # list with len=2
⋮ ⋮ ⋮ 3,
⋮ ⋮ ⋮ [ # list with len=2 ... ],
⋮ ⋮ ],
⋮ ],
]

>>> torch.tensor([1, 2]) | aprint # pipeline print (only for torch.Tensor and built-in iterators)
int64[2] torch.Tensor at 'cpu' with grad=False

Roadmap

  • pipeline support for torch.Tensor
  • continuous integration
  • support class inheritance
    • support iterators' classes
    • support objects' classes
  • support more types
    • torch.nn.parameter.Parameter
  • colorful output
  • glance of the data

License

MIT License

Metadata

Release files for aprint 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aprint 0.0.2
File Size Uploaded
aprint-0.0.2.tar.gz 6.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aprint 0.0.2
File Interpreter ABI Platform
aprint-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 14.3 kB

Release files / aprint-0.0.2.tar.gz

Download URL aprint-0.0.2.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
456d5becdff385f7cda4403c8ea2eb6996863ddbf88db88b2d12b6b48d0cd4d2
BLAKE2b-256 checksum
How to use checksums
b5b4d27c186df8bc99c8c420a79e0fea26bb3bbd513455a3ca9be51ac43e3c20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.5

Release files / aprint-0.0.2-py3-none-any.whl

Download URL aprint-0.0.2-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ec68ded59528c191791e4152e0715609835ad8f4bfcff45ce756883a6954911b
BLAKE2b-256 checksum
How to use checksums
3b331cc9aca98a21dca98c6896bafd9a7a1e61257d712220a9f7d962547ed9ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.5

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page