{ "info": { "author": "Ryan Turner", "author_email": "rdturnermtl@github.com", "bugtrack_url": null, "classifiers": [ "Framework :: Hypothesis", "Framework :: Pytest", "Intended Audience :: Developers", "Operating System :: POSIX", "Operating System :: Unix", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Testing" ], "description": "===================\nHypothesis GU Funcs\n===================\n\n.. image:: https://api.travis-ci.com/uber/hypothesis-gufunc.png?token=RSemjpisB7uiZv78DVwd&branch=master\n :target: https://travis-ci.com/uber/hypothesis-gufunc\n\nThis project is experimental and the APIs are not considered stable.\n\nOnly `Python>=3.6` is officially supported, but older versions of Python likely work as well.\n\nThis package includes support for strategies which generate arguments to\nfunctions that follow the numpy general universal function API. So, it can\nautomatically generate the matrices with shapes that follow the shape\nconstraints. For example, to generate test inputs for `np.dot`, one can use,\n\n.. code-block:: python\n\n import numpy as np\n from hypothesis import given\n from hypothesis.strategies import floats\n from hypothesis_gufunc.gufunc import gufunc_args\n\n easy_floats = floats(min_value=-10, max_value=10)\n\n @given(gufunc_args('(m,n),(n,p)->(m,p)', dtype=np.float_, elements=easy_floats))\n def test_np_dot(args):\n x, y = args\n assert np.allclose(np.dot(x, y), np.dot(y.T, x.T).T)\n\n test_np_dot() # Run the test\n\nWe also allow for adding extra dimensions that follow the numpy broadcasting\nconventions. This allows one to test that the broadcasting follows the\nvectorization conventions:\n\n.. code-block:: python\n\n @given(gufunc_args('(m,n),(n,p)->(m,p)', dtype=np.float_, elements=easy_floats, max_dims_extra=3))\n def test_np_matmul(args):\n x, y = args\n f_vec = np.vectorize(np.matmul, signature='(m,n),(n,p)->(m,p)', otypes=[np.float_])\n assert np.allclose(np.matmul(x, y), f_vec(x, y))\n\n test_np_matmul() # Run the test\n\nProviding `max_dims_extra=3` gives up to 3 broadcast compatible dimensions on each of the arguments.\n\n------------------------\nQuick Start/Installation\n------------------------\n\nSimply install with pip:\n\n.. code-block::\n\n pip install hypothesis-gufunc\n\nIf one would like the same pinned requirements we use during testing, then one can install from the repo with:\n\n.. code-block::\n\n git clone git@github.com:uber/hypothesis-gufunc.git\n cd hypothesis-gufunc\n pip install -r requirements/base.txt\n pip install -e .\n\n-----------------\nRunning the Tests\n-----------------\n\nThe tests for this package can be run by first doing a `cd` to its root directory and then\n\n.. code-block::\n\n ./test.sh\n\nThe script creates a conda environment using the requirements found in `requirements/test.txt`.\n\n---------------------\nHypothesis for Xarray\n---------------------\n\nThis package also contains an extension to hypothesis to generate xarray data structures.\n\nTo install the package with the xarray dependencies install it with pip as\n\n.. code-block::\n\n pip install hypothesis-gufunc[xarray]\n\nOnce installed, one can generate a data array as follows:\n\n.. code-block:: python\n\n from hypothesis.strategies import integers, lists\n from hypothesis_gufunc.extra.xr import fixed_dataarrays\n\n S = fixed_dataarrays((\"a\", \"b\"), coords_st={\"a\": lists(integers(0, 3))})\n S.example()\n\nHere, `coords_st` allows one to specify a custom strategy for the coordinates on a per-dimension basis. Likewise, if\none has known coordinates one can call `fixed_coords_dataarrays`; or\n`dataarrays` if one wants both the dimensions and coordinates determined by the\nstrategy.\n\nThe package also has the ability to generate a dataset:\n\n.. code-block:: python\n\n from hypothesis_gufunc.extra.xr import fixed_datasets\n\n S = fixed_datasets({5: (\"a\", \"b\"), \"bar\": (\"b\"), \"baz\": ()}, coords_st={\"a\": lists(integers(0, 3))})\n S.example()\n\nOne can use `fixed_coords_datasets` when the coordinates are determined; or simply\n`datasets` to have both the dimensions and coordinates generated.\n\n-----\nLinks\n-----\n\nThe `source `_ is hosted on GitHub.\n\nThe `documentation `_ is hosted at Read the Docs.\n\nThe main `hypothesis project `_.\n\nA description of the numpy\n`Generalized Universal Function API `_.\n\nLikewise, the numpy broadcasting rules are described\n`here `_.\n\nThe `xarray `_ project describes data arrays and datasets.\n\n-------\nLicense\n-------\n\nThis project is licensed under the Apache 2 License - see the LICENSE file for details.", "description_content_type": "text/x-rst", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/uber/hypothesis-gufunc", "keywords": "", "license": "Apache v2", "maintainer": "", "maintainer_email": "", "name": "hypothesis-gufunc", "package_url": "https://pypi.org/project/hypothesis-gufunc/", "platform": "any", "project_url": "https://pypi.org/project/hypothesis-gufunc/", "project_urls": { "Documentation": "https://hypothesis-gufunc.readthedocs.io", "Homepage": "https://github.com/uber/hypothesis-gufunc" }, "release_url": "https://pypi.org/project/hypothesis-gufunc/0.0.5/", "requires_dist": null, "requires_python": "", "summary": "Extension to hypothesis to generate inputs for general universal (GU) numpy functions.", "version": "0.0.5" }, "last_serial": 5876720, "releases": { "0.0.3": [ { "comment_text": "", "digests": { "md5": "86408b97d4dd1cbcaa4ff3b71c3e4dc6", "sha256": "fb5b0c42265a72034effd9c94b393a858d0946f9bcf224c156b33b3503b09855" }, "downloads": -1, "filename": "hypothesis_gufunc-0.0.3.tar.gz", "has_sig": false, "md5_digest": "86408b97d4dd1cbcaa4ff3b71c3e4dc6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11606, "upload_time": "2019-08-16T23:48:46", "url": "https://files.pythonhosted.org/packages/3d/1e/3465353b81eb0c70ac496d218a4829eba0f17ef217abb58b1d9f2ce71cd3/hypothesis_gufunc-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "9a2a204669b8944d315aff54bf6465f8", "sha256": "03486bdb984d3f72de5da3b2621e4f10c71a5084c296cf3b0c79de7093d1dbb0" }, "downloads": -1, "filename": "hypothesis_gufunc-0.0.4.tar.gz", "has_sig": false, "md5_digest": "9a2a204669b8944d315aff54bf6465f8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12314, "upload_time": "2019-08-18T19:25:18", "url": "https://files.pythonhosted.org/packages/f9/e8/693c813c6c0c2285150b59cf9027265ad5751655882bec21a3b836f02f44/hypothesis_gufunc-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "0bc86aee1687498238233e0e52ce6692", "sha256": "5a4e03b210c16cc7932c7dd82fb44dd8870011af0ebdceac3114ab0c15c7c2b6" }, "downloads": -1, "filename": "hypothesis_gufunc-0.0.5.tar.gz", "has_sig": false, "md5_digest": "0bc86aee1687498238233e0e52ce6692", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16565, "upload_time": "2019-09-24T00:33:16", "url": "https://files.pythonhosted.org/packages/73/9b/826b0e54dd45aab73b5a50495dbe3e5b973027f6a1be4aa40eb1e4be3433/hypothesis_gufunc-0.0.5.tar.gz" } ], "0.0.5rc2": [ { "comment_text": "", "digests": { "md5": "a48843c85b3b26f2ae36a80b295533f0", "sha256": "6ced15c20752fc887da63bc393ab6af788626cff513a36858f2ca823ce3ae1ba" }, "downloads": -1, "filename": "hypothesis_gufunc-0.0.5rc2.tar.gz", "has_sig": false, "md5_digest": "a48843c85b3b26f2ae36a80b295533f0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16558, "upload_time": "2019-09-06T20:07:22", "url": "https://files.pythonhosted.org/packages/04/8f/facddaae6f818a08010947b13b2e9f6fc63a767985cd8922827d7091fcc2/hypothesis_gufunc-0.0.5rc2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0bc86aee1687498238233e0e52ce6692", "sha256": "5a4e03b210c16cc7932c7dd82fb44dd8870011af0ebdceac3114ab0c15c7c2b6" }, "downloads": -1, "filename": "hypothesis_gufunc-0.0.5.tar.gz", "has_sig": false, "md5_digest": "0bc86aee1687498238233e0e52ce6692", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16565, "upload_time": "2019-09-24T00:33:16", "url": "https://files.pythonhosted.org/packages/73/9b/826b0e54dd45aab73b5a50495dbe3e5b973027f6a1be4aa40eb1e4be3433/hypothesis_gufunc-0.0.5.tar.gz" } ] }