# 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](https://julialang.org/), 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 git+https://github.com/huangyuxi/aprint.git
```
## Usage
```python
>>> 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 ... ],
⋮ ⋮ ],
⋮ ],
]
```
## Future Work
- [ ] support more types
- [ ] colorful output
- [ ] glance of the data
## License
MIT License
Raw data
{
"_id": null,
"home_page": "https://github.com/huangyxi/aprint",
"name": "aprint",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "aprint,print",
"author": "HUANG Yuxi",
"author_email": "aprint@hyxi.dev",
"download_url": "https://files.pythonhosted.org/packages/94/a9/ac3e49bf978066efb77281ac622170f0892a02e4c1f0d761094c6ddb7958/aprint-0.0.1.tar.gz",
"platform": "any",
"description": "# aprint\n\nA 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.\n\n\n## Background\n\nBy 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.\nInspired by the leading scientific computing language [Julia](https://julialang.org/), 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.\n\n\n## Installation\n\n```\npip install git+https://github.com/huangyuxi/aprint.git\n```\n\n## Usage\n\n```python\n>>> import numpy as np\n>>> import torch\n>>> from aprint import aprint\n\n>>> aprint(np.array([1, 2, 3]))\nint64[3] numpy.ndarray\n\n>>> 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='| ')\n{ # dict with len=2\n| 'a': float32[16\u00d732] torch.Tensor at 'cuda:0' with grad=False,\n| 2: [ # list with len=3\n| | int64[2] numpy.ndarray,\n| | ( # tuple with len=3\n| | | float32[2] torch.Tensor at 'cpu' with layout='COO', grad=False,\n| | | float32[2\u00d73] torch.Tensor at 'cpu' with layout='CSR', grad=False,\n| | | float32[2\u00d73\u00d74] torch.Tensor at 'cpu' with layout='CSC', grad=False,\n| | ),\n| | { # set with len=3\n| | | '5',\n| | | 6,\n| | | 7.0,\n| | },\n| ],\n}\n\n>>> aprint([1, [2, [3, [4, [5]]]]], max_depth=3, indent_str=\"\u22ee \") # default max_depth=5\n[ # list with len=2\n\u22ee 1,\n\u22ee [ # list with len=2\n\u22ee \u22ee 2,\n\u22ee \u22ee [ # list with len=2\n\u22ee \u22ee \u22ee 3,\n\u22ee \u22ee \u22ee [ # list with len=2 ... ],\n\u22ee \u22ee ],\n\u22ee ],\n]\n```\n\n## Future Work\n\n- [ ] support more types\n- [ ] colorful output\n- [ ] glance of the data\n\n\n## License\n\nMIT License\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "A function to print arrays in a concise way",
"version": "0.0.1",
"project_urls": {
"Homepage": "https://github.com/huangyxi/aprint"
},
"split_keywords": [
"aprint",
"print"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "94a9ac3e49bf978066efb77281ac622170f0892a02e4c1f0d761094c6ddb7958",
"md5": "12d62032ea34cac76cb2abf5c3b8f8a5",
"sha256": "9d4e1dbb8948392ec26f331216766e6fa6fccd30e18e11629dbb81da7735fbec"
},
"downloads": -1,
"filename": "aprint-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "12d62032ea34cac76cb2abf5c3b8f8a5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5784,
"upload_time": "2023-09-06T01:47:53",
"upload_time_iso_8601": "2023-09-06T01:47:53.483715Z",
"url": "https://files.pythonhosted.org/packages/94/a9/ac3e49bf978066efb77281ac622170f0892a02e4c1f0d761094c6ddb7958/aprint-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-06 01:47:53",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "huangyxi",
"github_project": "aprint",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "aprint"
}