{ "info": { "author": "Thomas Robitaille", "author_email": "thomas.robitaille@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Framework :: Pytest", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Software Development :: Testing" ], "description": "|Travis Build Status| |AppVeyor Build status| |Coverage|\n\nAbout\n-----\n\nThis is a `py.test `__ plugin to facilitate the\ngeneration and comparison of data arrays produced during tests, in particular\nin cases where the arrays are too large to conveniently hard-code them\nin the tests (e.g. ``np.testing.assert_allclose(x, [1, 2, 3])``).\n\nThe basic idea is that you can write a test that generates a Numpy array (or\nother related objects depending on the format). You can then either run the\ntests in a mode to **generate** reference files from the arrays, or you can run\nthe tests in **comparison** mode, which will compare the results of the tests to\nthe reference ones within some tolerance.\n\nAt the moment, the supported file formats for the reference files are:\n\n- A plain text-based format (baed on Numpy ``loadtxt`` output)\n- The FITS format (requires `astropy `__). With this\n format, tests can return either a Numpy array for a FITS HDU object.\n\nFor more information on how to write tests to do this, see the **Using**\nsection below.\n\nInstalling\n----------\n\nThis plugin is compatible with Python 2.7, and 3.5 and later, and\nrequires `pytest `__ and\n`numpy `__ to be installed.\n\nTo install, you can do::\n\n pip install pytest-arraydiff\n\nYou can check that the plugin is registered with pytest by doing::\n\n py.test --version\n\nwhich will show a list of plugins::\n\n This is pytest version 2.7.1, imported from ...\n setuptools registered plugins:\n pytest-arraydiff-0.1 at ...\n\nUsing\n-----\n\nTo use, you simply need to mark the function where you want to compare\narrays using ``@pytest.mark.array_compare``, and make sure that the\nfunction returns a plain Numpy array::\n\n python\n import pytest\n import numpy as np\n\n @pytest.mark.array_compare\n def test_succeeds():\n return np.arange(3 * 5 * 4).reshape((3, 5, 4))\n\nTo generate the reference data files, run the tests with the\n``--arraydiff-generate-path`` option with the name of the directory\nwhere the generated files should be placed::\n\n py.test --arraydiff-generate-path=reference\n\nIf the directory does not exist, it will be created. The directory will\nbe interpreted as being relative to where you are running ``py.test``.\nMake sure you manually check the reference arrays to ensure they are\ncorrect.\n\nOnce you are happy with the generated data files, you should move them\nto a sub-directory called ``reference`` relative to the test files (this\nname is configurable, see below). You can also generate the baseline\narrays directly in the right directory.\n\nYou can then run the tests simply with::\n\n py.test --arraydiff\n\nand the tests will pass if the arrays are the same. If you omit the\n``--arraydiff`` option, the tests will run but will only check that the\ncode runs without checking the output arrays.\n\nOptions\n-------\n\nThe ``@pytest.mark.array_compare`` marker take an argument to specify\nthe format to use for the reference files:\n\n.. code:: python\n\n @pytest.mark.array_compare(file_format='text')\n def test_array():\n ...\n\nThe default file format can also be specified using the\n``--arraydiff-default-format=`` flag when running ``py.test``,\nand ```` should be either ``fits`` or ``text``.\n\nThe supported formats at this time are ``text`` and ``fits``, and\ncontributions for other formats are welcome. The default format is\n``text``.\n\nAnother argument is the relative tolerance for floating point values\n(which defaults to 1e-7):\n\n.. code:: python\n\n @pytest.mark.array_compare(rtol=20)\n def test_array():\n ...\n\nYou can also pass keyword arguments to the writers using the\n``write_kwargs``. For the ``text`` format, these arguments are passed to\n``savetxt`` while for the ``fits`` format they are passed to Astropy's\n``fits.writeto`` function.\n\n.. code:: python\n\n @pytest.mark.array_compare(file_format='fits', write_kwargs={'output_verify': 'silentfix'})\n def test_array():\n ...\n\nOther options include the name of the reference directory (which\ndefaults to ``reference`` ) and the filename for the reference file\n(which defaults to the name of the test with a format-dependent\nextension).\n\n.. code:: python\n\n @pytest.mark.array_compare(reference_dir='baseline_arrays',\n filename='other_name.fits')\n def test_array():\n ...\n\nThe reference directory in the decorator above will be interpreted as\nbeing relative to the test file. Note that the baseline directory can\nalso be a URL (which should start with ``http://`` or ``https://`` and\nend in a slash).\n\nFinally, you can also set a custom baseline directory globally when\nrunning tests by running ``py.test`` with::\n\n py.test --arraydiff --arraydiff-reference-path=baseline_arrays\n\nThis directory will be interpreted as being relative to where the tests\nare run. In addition, if both this option and the ``reference_dir``\noption in the ``array_compare`` decorator are used, the one in the\ndecorator takes precedence.\n\nTest failure example\n--------------------\n\nIf the arrays produced by the tests are correct, then the test will\npass, but if they are not, the test will fail with a message similar to\nthe following::\n\n E AssertionError:\n E\n E a: /var/folders/zy/t1l3sx310d3d6p0kyxqzlrnr0000gr/T/tmpbvjkzt_q/test_to_mask_rect-mode_subpixels-subpixels_18.txt\n E b: /var/folders/zy/t1l3sx310d3d6p0kyxqzlrnr0000gr/T/tmpbvjkzt_q/reference-test_to_mask_rect-mode_subpixels-subpixels_18.txt\n E\n E Not equal to tolerance rtol=1e-07, atol=0\n E\n E (mismatch 47.22222222222222%)\n E x: array([[ 0. , 0. , 0. , 0. , 0.404012, 0.55 ,\n E 0.023765, 0. , 0. ],\n E [ 0. , 0. , 0. , 0.112037, 1.028704, 1.1 ,...\n E y: array([[ 0. , 0. , 0. , 0. , 0.367284, 0.5 ,\n E 0.021605, 0. , 0. ],\n E [ 0. , 0. , 0. , 0.101852, 0.935185, 1. ,...\n\nThe file paths included in the exception are then available for\ninspection.\n\nRunning the tests for pytest-arraydiff\n--------------------------------------\n\nIf you are contributing some changes and want to run the tests, first\ninstall the latest version of the plugin then do::\n\n cd tests\n py.test --arraydiff\n\nThe reason for having to install the plugin first is to ensure that the\nplugin is correctly loaded as part of the test suite.\n\n.. |Travis Build Status| image:: https://travis-ci.org/astrofrog/pytest-arraydiff.svg?branch=master\n :target: https://travis-ci.org/astrofrog/pytest-arraydiff\n.. |AppVeyor Build status| image:: https://ci.appveyor.com/api/projects/status/0nech6qgp8jlabjp/branch/master?svg=true\n :target: https://ci.appveyor.com/project/astropy/pytest-arraydiff\n.. |Coverage| image:: https://codecov.io/gh/astropy/pytest-arraydiff/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/astropy/pytest-arraydiff\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/astrofrog/pytest-arraydiff", "keywords": "", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "pytest-arraydiff", "package_url": "https://pypi.org/project/pytest-arraydiff/", "platform": "", "project_url": "https://pypi.org/project/pytest-arraydiff/", "project_urls": { "Homepage": "https://github.com/astrofrog/pytest-arraydiff" }, "release_url": "https://pypi.org/project/pytest-arraydiff/0.3/", "requires_dist": [ "numpy", "six", "pytest" ], "requires_python": "", "summary": "pytest plugin to help with comparing array output from tests", "version": "0.3" }, "last_serial": 5848221, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "024bff8dc06fb2e158956d3c70ae5334", "sha256": "4ca5aaa9a8dc55f0cf621ce6cca3060e320e32b1a500e2f87298ade0a5ece7e1" }, "downloads": -1, "filename": "pytest-arraydiff-0.1.tar.gz", "has_sig": false, "md5_digest": "024bff8dc06fb2e158956d3c70ae5334", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8752, "upload_time": "2016-11-26T13:16:22", "url": "https://files.pythonhosted.org/packages/04/65/5d1c98e6f9f8ff97f771d9bc7a349948418f9a7e86c9285f63853861af51/pytest-arraydiff-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "b6791e08a998d8ce508056ad50513bcf", "sha256": "0bc7ae769bfe02e7f797c1251481d0490fedfa5092c1ededa039cd3a316df850" }, "downloads": -1, "filename": "pytest_arraydiff-0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b6791e08a998d8ce508056ad50513bcf", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 11580, "upload_time": "2018-01-29T10:18:03", "url": "https://files.pythonhosted.org/packages/c5/13/fbaf81f14374c2a27782ed43a5e035d80af15982e27cc04888a1d3c8c244/pytest_arraydiff-0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1c84bdfc49347af1d8eceb47c23655ad", "sha256": "0145edfa8830aba07150fc09443da74d0ec4074e3de702445453415a744d3ad9" }, "downloads": -1, "filename": "pytest-arraydiff-0.2.tar.gz", "has_sig": false, "md5_digest": "1c84bdfc49347af1d8eceb47c23655ad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12838, "upload_time": "2018-01-29T10:18:09", "url": "https://files.pythonhosted.org/packages/c6/16/4f36013c37e7adabbdb4db10b39a69ca8e4723ea144ef700409480b7591b/pytest-arraydiff-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "facfb0e447d9d85e3e0813449da629da", "sha256": "7d981cf9c09178f40d00c7b791a226438a2c1b46f210ddaaaa1c6aa63cae6456" }, "downloads": -1, "filename": "pytest_arraydiff-0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "facfb0e447d9d85e3e0813449da629da", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8153, "upload_time": "2018-12-06T04:31:20", "url": "https://files.pythonhosted.org/packages/b2/dd/0096e95a7da9d6cd566c35bd85b97659303007c2e8a3573c5d51fbf5da3d/pytest_arraydiff-0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5d9af26545c15eaceee403f6cab6261d", "sha256": "de2d62f53ecc107ed754d70d562adfa7573677a263216a7f19aa332f20dc6c15" }, "downloads": -1, "filename": "pytest-arraydiff-0.3.tar.gz", "has_sig": false, "md5_digest": "5d9af26545c15eaceee403f6cab6261d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11167, "upload_time": "2018-12-06T04:31:22", "url": "https://files.pythonhosted.org/packages/36/f1/7f637181ee9d8a175ac3090cd91cf3b3a367eac223cad7c3a747a6f7009f/pytest-arraydiff-0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "facfb0e447d9d85e3e0813449da629da", "sha256": "7d981cf9c09178f40d00c7b791a226438a2c1b46f210ddaaaa1c6aa63cae6456" }, "downloads": -1, "filename": "pytest_arraydiff-0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "facfb0e447d9d85e3e0813449da629da", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8153, "upload_time": "2018-12-06T04:31:20", "url": "https://files.pythonhosted.org/packages/b2/dd/0096e95a7da9d6cd566c35bd85b97659303007c2e8a3573c5d51fbf5da3d/pytest_arraydiff-0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5d9af26545c15eaceee403f6cab6261d", "sha256": "de2d62f53ecc107ed754d70d562adfa7573677a263216a7f19aa332f20dc6c15" }, "downloads": -1, "filename": "pytest-arraydiff-0.3.tar.gz", "has_sig": false, "md5_digest": "5d9af26545c15eaceee403f6cab6261d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11167, "upload_time": "2018-12-06T04:31:22", "url": "https://files.pythonhosted.org/packages/36/f1/7f637181ee9d8a175ac3090cd91cf3b3a367eac223cad7c3a747a6f7009f/pytest-arraydiff-0.3.tar.gz" } ] }