Skip to main content

A library to get a text summary of nested objects

Reason this release was yanked:

use pip install coola for a better implementation

Project description

arctix

CI CI Codecov
PYPI version Python BSD-3-Clause Code style: black Doc style: google
Downloads Monthly downloads

Overview

arctix is a Python library that provides simple functions to check in a single line if two complex/nested objects are equal or not. arctix was initially designed to work with PyTorch Tensors and NumPy ndarray, but it is possible to extend it to support other data structures.

Motivation

Let's imagine you have the following dictionaries that contain both a PyTorch Tensor and a NumPy ndarray. You want to compute a string representation of it. By default, Python tries to show the values of all the tensor/array. The arctix library was developed to easily compute structured string representation of nested objects. arctix provides a function summary that can indicate if two complex/nested objects are equal or not.

>>> import numpy
>>> import torch
>>> from arctix import summary
>>> print(summary({"torch": torch.ones(2, 3), "numpy": numpy.zeros((2, 3))}))
<class 'dict'> (length=2)
  (torch): <class 'torch.Tensor'> | shape=torch.Size([2, 3]) | dtype=torch.float32 | device=cpu
  (numpy): <class 'numpy.ndarray'> | shape=(2, 3) | dtype=float64
>>> print(
...     summary(
...         {
...             "torch": [torch.ones(2, 3), torch.zeros(6)],
...             "numpy": numpy.zeros((2, 3)),
...             "other": [42, 4.2, "abc"],
...         },
...         max_depth=3,
...     )
... )
<class 'dict'> (length=3)
  (torch): <class 'list'> (length=2)
      (0): <class 'torch.Tensor'> | shape=torch.Size([2, 3]) | dtype=torch.float32 | device=cpu
      (1): <class 'torch.Tensor'> | shape=torch.Size([6]) | dtype=torch.float32 | device=cpu
  (numpy): <class 'numpy.ndarray'> | shape=(2, 3) | dtype=float64
  (other): <class 'list'> (length=3)
      (0): <class 'int'> 42
      (1): <class 'float'> 4.2
      (2): <class 'str'> abc

Please check the quickstart page to learn more on how to use arctix.

Installation

We highly recommend installing a virtual environment. arctix can be installed from pip using the following command:

pip install arctix

To make the package as slim as possible, only the minimal packages required to use arctix are installed. To include all the packages, you can use the following command:

pip install arctix[all]

Please check the get started page to see how to install only some specific packages or other alternatives to install the library.

Contributing

Please check the instructions in CONTRIBUTING.md.

API stability

:warning: While arctix is in development stage, no API is guaranteed to be stable from one release to the next. In fact, it is very likely that the API will change multiple times before a stable 1.0.0 release. In practice, this means that upgrading arctix to a new version will possibly break any code that was using the old version of arctix.

License

arctix is licensed under BSD 3-Clause "New" or "Revised" license available in LICENSE file.

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

arctix-0.0.1.tar.gz (13.4 kB view hashes)

Uploaded Source

Built Distribution

arctix-0.0.1-py3-none-any.whl (14.4 kB view hashes)

Uploaded Python 3

Supported by

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