{ "info": { "author": "Applied Brain Research", "author_email": "info@appliedbrainresearch.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Framework :: Pytest", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3 :: Only" ], "description": "***************\npytest-allclose\n***************\n\n``pytest-allclose`` provides the `~.allclose` Pytest fixture,\nextending `numpy.allclose` with test-specific features.\n\nA core feature of the `~.allclose` fixture\nis that the tolerances for tests can be configured externally.\nThis allows different repositories to share the same tests,\nbut use different tolerances.\nSee the \"Configuration\" section below for details.\n\nInstallation\n============\n\nTo use this fixture, install with\n\n.. code-block:: bash\n\n pip install pytest-allclose\n\nUsage\n=====\n\nThe `~.allclose` fixture is used just like `numpy.allclose`.\n\n.. code-block:: python\n\n import numpy as np\n\n def test_close(allclose):\n x = np.linspace(-1, 1)\n y = x + 0.001\n assert allclose(y, x, atol=0.002)\n assert not allclose(y, x, atol=0.0005)\n assert not allclose(y, x, rtol=0.002)\n\nAdditional arguments\n--------------------\n\nThe `~.allclose` fixture has a number of arguments\nthat are not part of `numpy.allclose`.\nOne such argument is ``xtol``,\nwhich allows arrays that have been shifted along their first axis\nby a certain number of steps to be considered close.\n\n.. code-block:: python\n\n import numpy as np\n\n def test_close(allclose):\n x = np.linspace(-1, 1)\n\n assert allclose(x[1:], x[:-1], xtol=1)\n assert allclose(x[3:], x[:-3], xtol=3)\n assert not allclose(x[3:], x[:-3], xtol=1)\n\nRefer to the `~.allclose` API reference for all additional arguments.\n\nRMSE error reporting\n--------------------\n\nThe `~.allclose` fixture stores root-mean-square error values,\nwhich can be reported in the pytest terminal summary.\nTo do so, put the following in your ``conftest.py`` file.\n\n.. code-block:: python\n\n from pytest_allclose import report_rmses\n\n def pytest_terminal_summary(terminalreporter):\n report_rmses(terminalreporter)\n\nSee the `~.report_rmses` API reference for more information.\n\nConfiguration\n=============\n\nallclose_tolerances\n-------------------\n\n``allclose_tolerances`` accepts a list of test name patterns,\nfollowed by values for any of the `~.allclose` parameters.\nThese values will override any values provided within the test function itself,\nallowing multiple repositories to use the same test suite,\nbut with different tolerances.\n\n.. code-block:: ini\n\n allclose_tolerances =\n test_file.py:test_function atol=0.3 # set atol for specific test\n test_file.py:test_func* rtol=0.2 # set rtol for tests matching wildcard\n test_file.py:* atol=0.1 rtol=0.3 # set both tols for all tests in file\n test_*tion rtol=0.2 # set rtol for all matching tests in any file\n test_function[True] atol=0.1 # set atol only for one parametrization\n\nThe only special character recognized in these patterns\nis the wildcard character ``*``,\nwhich matches any group of zero or more characters.\n\nIf the test is parametrized,\nthen a pattern like ``test_name[param0-param1]``\nwill match specific parameter settings,\nand ``test_name*`` will match all parameter settings.\nNote that the latter will match any test that starts with ``test_name``.\n\nIf a test has multiple `~.allclose` calls,\nyou can use multiple tolerance lines that match the same test\nto set different values for the first, second, third, etc. calls.\nIf there are more `~.allclose` calls than tolerance lines,\nthe last tolerance line will be used for all remaining `~.allclose` calls.\n\nExample test file:\n\n.. code-block:: python\n\n def test_close(allclose):\n x = np.linspace(-1, 1)\n y = x + 0.001\n assert allclose(y, x)\n assert not allclose(y, x)\n\nExample configuration file (``pytest.ini``, ``setup.cfg``):\n\n.. code-block:: ini\n\n allclose_tolerances =\n test_close atol=0.002 # affects first allclose call\n test_close atol=0.0005 # affects second allclose call\n\n.. note:: Different tolerance lines correspond to *calls* of the\n function, not lines of code. If you have a ``for``\n loop that calls `~.allclose` 3 times,\n each of these calls corresponds to a new tolerance line.\n If you have a fourth `~.allclose` call,\n you would need three tolerance lines for the three calls\n in the ``for`` loop, then a fourth line for the last call.\n\n.. caution:: The patterns for multiple calls of allclose in a function\n must be exactly the same.\n This means that if you have specific values for one\n parametrization and general values for others,\n you must put the specific values first\n or they will not have any effect.\n\n Good example, specific takes precedence:\n\n .. code-block:: ini\n\n allclose_tolerances =\n test_close[True-1] atol=0.002\n test_close[True-1] atol=0.0005\n test_close* atol=0.001\n test_close* atol=0.0001\n\n Bad example, general takes precedence:\n\n .. code-block:: ini\n\n allclose_tolerances =\n test_close* atol=0.001\n test_close* atol=0.0001\n test_close[True-1] atol=0.002\n test_close[True-1] atol=0.0005\n\nSee the full\n`documentation `__\nfor the API reference.\n\n***************\nRelease History\n***************\n\n.. Changelog entries should follow this format:\n\n version (release date)\n ======================\n\n **section**\n\n - One-line description of change (link to Github issue/PR)\n\n.. Changes should be organized in one of several sections:\n\n - Added\n - Changed\n - Deprecated\n - Removed\n - Fixed\n\n1.0.0 (July 30, 2019)\n=====================\n\nInitial release of ``pytest-allclose``!\nThanks to all of the contributors for making this possible!\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://www.nengo.ai/pytest-allclose", "keywords": "", "license": "MIT license", "maintainer": "", "maintainer_email": "", "name": "pytest-allclose", "package_url": "https://pypi.org/project/pytest-allclose/", "platform": "", "project_url": "https://pypi.org/project/pytest-allclose/", "project_urls": { "Homepage": "https://www.nengo.ai/pytest-allclose" }, "release_url": "https://pypi.org/project/pytest-allclose/1.0.0/", "requires_dist": [ "numpy (>=1.11)", "pytest", "nengo-sphinx-theme (>=1.0) ; extra == 'all'", "sphinx ; extra == 'all'", "codespell ; extra == 'all'", "coverage (>=4.3) ; extra == 'all'", "flake8 ; extra == 'all'", "gitlint ; extra == 'all'", "pylint ; extra == 'all'", "nengo-sphinx-theme (>=1.0) ; extra == 'docs'", "sphinx ; extra == 'docs'", "codespell ; extra == 'tests'", "coverage (>=4.3) ; extra == 'tests'", "flake8 ; extra == 'tests'", "gitlint ; extra == 'tests'", "pylint ; extra == 'tests'" ], "requires_python": ">=3.5", "summary": "Pytest fixture extending Numpy's allclose function", "version": "1.0.0" }, "last_serial": 5608018, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "fceeb16a03be7a567e559c4a36ee17e7", "sha256": "ee1a0d5dd0322c2439aa30883ca6748f18150e7e708209852a4b67444790bc97" }, "downloads": -1, "filename": "pytest_allclose-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "fceeb16a03be7a567e559c4a36ee17e7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 8441, "upload_time": "2019-07-30T14:24:56", "url": "https://files.pythonhosted.org/packages/c2/95/afa083bad44faa65048a9fbc018e9bc1b40045d4232383e723a555cd8b7c/pytest_allclose-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f8d65c9ec1933528a27f9d4f34c1b9e2", "sha256": "b2f0c521fa652281400d4a105c84454db3c50b993bcfee9861380be69cc6b041" }, "downloads": -1, "filename": "pytest-allclose-1.0.0.tar.gz", "has_sig": false, "md5_digest": "f8d65c9ec1933528a27f9d4f34c1b9e2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 18625, "upload_time": "2019-07-30T14:24:59", "url": "https://files.pythonhosted.org/packages/7a/7c/2b82fafea079feb080404b7611a4d07313ae816d2a35e7f2df084a3e002b/pytest-allclose-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "fceeb16a03be7a567e559c4a36ee17e7", "sha256": "ee1a0d5dd0322c2439aa30883ca6748f18150e7e708209852a4b67444790bc97" }, "downloads": -1, "filename": "pytest_allclose-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "fceeb16a03be7a567e559c4a36ee17e7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 8441, "upload_time": "2019-07-30T14:24:56", "url": "https://files.pythonhosted.org/packages/c2/95/afa083bad44faa65048a9fbc018e9bc1b40045d4232383e723a555cd8b7c/pytest_allclose-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f8d65c9ec1933528a27f9d4f34c1b9e2", "sha256": "b2f0c521fa652281400d4a105c84454db3c50b993bcfee9861380be69cc6b041" }, "downloads": -1, "filename": "pytest-allclose-1.0.0.tar.gz", "has_sig": false, "md5_digest": "f8d65c9ec1933528a27f9d4f34c1b9e2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 18625, "upload_time": "2019-07-30T14:24:59", "url": "https://files.pythonhosted.org/packages/7a/7c/2b82fafea079feb080404b7611a4d07313ae816d2a35e7f2df084a3e002b/pytest-allclose-1.0.0.tar.gz" } ] }