File: comparison.py

package info (click to toggle)
python-ase 3.26.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,484 kB
  • sloc: python: 148,112; xml: 2,728; makefile: 110; javascript: 47
file content (12 lines) | stat: -rw-r--r-- 399 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
# fmt: off
import numpy as np
import pytest


def compare_with_pytest_approx(quantity, expected_values, rel_tol):
    """
    Cast inputted objects to numpy arrays and assert equivalence via
    pytest.approx with the requested relative tolerance
    """
    quantity, expected_values = map(np.asarray, [quantity, expected_values])
    assert quantity == pytest.approx(expected_values, rel=rel_tol)