From 7bb164120be5078642c180f4bd20d7629ce38313 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Fri, 20 Jan 2023 11:44:31 +0000 Subject: [PATCH] tests: fuzzy test for Obs added, test dependencies and documentation updated. --- .github/workflows/pytest.yml | 1 + CONTRIBUTING.md | 4 +++- pyerrors/obs.py | 1 + setup.py | 2 +- tests/obs_test.py | 6 ++++++ 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 536f7d53..5321d1ae 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -40,6 +40,7 @@ jobs: pip install pytest pip install pytest-cov pip install pytest-benchmark + pip install hypothesis pip install py pip freeze diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 98ab0c75..8d803e4a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,7 +25,9 @@ For all pull requests tests are executed for the most recent python releases via pytest -vv --cov=pyerrors pytest -vv --nbmake examples/*.ipynb ``` -requiring `pytest`, `pytest-cov`, `pytest-benchmark` and `nbmake`. To get a coverage report in html run +requiring `pytest`, `pytest-cov`, `pytest-benchmark`, `hypothesis' and `nbmake`. To install the test dependencies one can run `pip install pyerrors[test]` + +To get a coverage report in html run ``` pytest --cov=pyerrors --cov-report html ``` diff --git a/pyerrors/obs.py b/pyerrors/obs.py index 9df6b5c2..d56e34ea 100644 --- a/pyerrors/obs.py +++ b/pyerrors/obs.py @@ -10,6 +10,7 @@ import matplotlib.pyplot as plt from scipy.stats import skew, skewtest, kurtosis, kurtosistest import numdifftools as nd from itertools import groupby +from hypothesis import given, strategies as st from .covobs import Covobs # Improve print output of numpy.ndarrays containing Obs objects. diff --git a/setup.py b/setup.py index 3aa4d889..6ad29512 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ setup(name='pyerrors', packages=find_packages(), python_requires='>=3.7.0', install_requires=['numpy>=1.19', 'autograd>=1.5', 'numdifftools>=0.9.41', 'matplotlib>=3.5', 'scipy>=1.7', 'iminuit>=2.17', 'h5py>=3.7', 'lxml>=4.9', 'python-rapidjson>=1.9', 'pandas>=1.1'], - extras_require={'test': ['pytest', 'pytest-cov', 'pytest-benchmark']}, + extras_require={'test': ['pytest', 'pytest-cov', 'pytest-benchmark', 'hypothesis']}, classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Science/Research', diff --git a/tests/obs_test.py b/tests/obs_test.py index 5fbedf98..aa6372d8 100644 --- a/tests/obs_test.py +++ b/tests/obs_test.py @@ -4,9 +4,15 @@ import copy import matplotlib.pyplot as plt import pyerrors as pe import pytest +from hypothesis import given, strategies as st np.random.seed(0) +@given(st.lists(st.floats(allow_nan=False, allow_infinity=False, width=32), min_size=5), st.text()) +def test_fuzzy_obs(data, string): + my_obs = pe.Obs([data], [string]) + my_obs * my_obs + def test_Obs_exceptions(): with pytest.raises(Exception):