Set of tools for comparing complex objects
Project description
Set of tools for comparing complex objects
Quickstart
approx is available on PyPI and can be installed with pip.
$ pip install approx
After installing approx you can use it like any other Python module.
Here is a simple example:
from approx import approx
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]]],
]
assert approx(item1, item2, rel_tol=1e-2)
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
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 Distributions
Built Distribution
File details
Details for the file approx-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: approx-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c9e12e73513b2d702582c8c526227924f0b036a80bd9f27feec2cb04d2f4f4a |
|
MD5 | d4ef69f1485dd16fdb33dd1b09121944 |
|
BLAKE2b-256 | 2e0de9a5ca81af1e08df3af8c2b73e2f7fe5e77d745432f7392a33a04abc29fa |