Skip to main content

A library to check if two complex/nested objects are equal or not

Project description

coola

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

Overview

coola is a Python library that provides simple functions to check in a single line if two complex/nested objects are equal or not. coola 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 check if the two dictionaries are equal or not. By default, Python does not provide an easy way to check if the two dictionaries are equal or not. It is not possible to use the default equality operator == because it will raise an error. The coola library was developed to fill this gap. coola provides a function objects_are_equal that can indicate if two complex/nested objects are equal or not.

>>> import numpy
>>> import torch
>>> from coola import objects_are_equal
>>> data1 = {"torch": torch.ones(2, 3), "numpy": numpy.zeros((2, 3))}
>>> data2 = {"torch": torch.zeros(2, 3), "numpy": numpy.ones((2, 3))}
>>> objects_are_equal(data1, data2)
False

coola also provides a function objects_are_allclose that can indicate if two complex/nested objects are equal within a tolerance or not.

>>> import numpy
>>> import torch
>>> from coola import objects_are_allclose
>>> data1 = {"torch": torch.ones(2, 3), "numpy": numpy.zeros((2, 3))}
>>> data2 = {"torch": torch.zeros(2, 3), "numpy": numpy.ones((2, 3))}
>>> objects_are_allclose(data1, data2, atol=1e-6)
False

The current supported types are:

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

Installation

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

pip install coola

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

pip install coola[all]

Please check the get started page to see how to install only some specific dependencies or other alternatives to install the library. The following is the corresponding coola versions and supported dependencies.

coola jax* numpy* pandas* polars* torch* xarray* python
0.0.23 >=0.3,<0.5 >=1.21,<1.27 >=1.3,<2.2 >=0.18.3,<0.20 >=1.10,<2.1 >=2023.3,<2023.9 >=3.9,<3.12
0.0.22 >=0.3,<0.5 >=1.20,<1.26 >=1.3,<2.1 >=0.18.3,<0.19 >=1.10,<2.1 >=2023.3,<2023.9 >=3.9,<3.12
0.0.21 >=0.3,<0.5 >=1.20,<1.26 >=1.3,<2.1 >=0.18.3,<0.19 >=1.10,<2.1 >=2023.3,<2023.8 >=3.9,<3.12
0.0.20 >=0.3,<0.5 >=1.20,<1.26 >=1.3,<2.1 >=0.18.3,<0.19 >=1.10,<2.1 >=2023.3,<2023.8 >=3.9

* indicates an optional dependency

Contributing

Please check the instructions in CONTRIBUTING.md.

API stability

:warning: While coola 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 coola to a new version will possibly break any code that was using the old version of coola.

License

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

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

coola-0.0.23.tar.gz (27.5 kB view details)

Uploaded Source

Built Distribution

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

coola-0.0.23-py3-none-any.whl (46.2 kB view details)

Uploaded Python 3

File details

Details for the file coola-0.0.23.tar.gz.

File metadata

  • Download URL: coola-0.0.23.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.13 Linux/6.2.0-1011-azure

File hashes

Hashes for coola-0.0.23.tar.gz
Algorithm Hash digest
SHA256 966fe57f87deb7511c9efe8c76a5c2125c529d1b16da09abf28fc29b5f60ef2c
MD5 0d8df5a5cb878d779b9b3b98414c520a
BLAKE2b-256 43cee0c657249d82deec759e3cab2e13ded8aaaedde9975c5507c6678ddd93c0

See more details on using hashes here.

File details

Details for the file coola-0.0.23-py3-none-any.whl.

File metadata

  • Download URL: coola-0.0.23-py3-none-any.whl
  • Upload date:
  • Size: 46.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.13 Linux/6.2.0-1011-azure

File hashes

Hashes for coola-0.0.23-py3-none-any.whl
Algorithm Hash digest
SHA256 9008e5c0d9cea6c325de4351620865c181c992912342f19a41de537e9840d127
MD5 8db27a8a1cd0629c6afe2ec8d6128e98
BLAKE2b-256 b1f5f92cfe0f9d71517cd7d52938ab0c0afb57d111a57d71590e2c5a42c5f300

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