Skip to main content

Set of tools for comparing complex objects

Project description

Set of tools for comparing complex objects

Quickstart

equator is available on PyPI and can be installed with pip.

$ pip install equator

After installing equator you can use it like any other Python module.

Here is a simple example:

from equator import equals

item1 = [
    {
        1: [
            {1: [1, 2]},
            [1, 2.0001],
        ],
    },
    [3, [4, [5]]],
]

item2 = [
    {
        1: [
            {1.0001: [1, 2.0001]},
            [1.0001, 1.9999],
        ],
    },
    [2.9999, [4, [5.002]]],
]

result = equals.approx(item1, item2, rel_tol=1e-2)
assert result

The function approx allows one to compare approximately objects of various types.

The motivation to create this function was that pytest.approx does not allow comparison of the complex objects. In contrast, this function allows one iterate through __dict__ of arbitrary objects and make use of math.isclose when encountering numeric types.

TODO

Currently one may expect issues with sets and Decimal.

Change Log

Version History

0.0.1
  • Project created.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

equator-0.0.1-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file equator-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: equator-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.0

File hashes

Hashes for equator-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a42f5ea14a65c1d6681f215a83aa1da1dcd41ce93507b06b68fe9a5f980aa00b
MD5 a4843a58e4939675fa0f82a652f56f27
BLAKE2b-256 d0bbf566ed918b6986f47aef1450e9073b4c22a17d6f85c0bfe6453c2c0f151d

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