{ "info": { "author": "The Bass", "author_email": "the-bass@posteo.co", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# Torch Testing\n\nA collection of assertion methods to compare PyTorch Tensors in tests.\n\nCurrently all assertion methods are provided by converting the tensors to numpy arrays and feeding them into an appropriate `numpy.testing` method. That way, on failure, detailed information is provided as to why the test failed.\n\nLast tested with **Python 3.6.4 :: Anaconda, Inc.** and **PyTorch 0.4**.\n\n## Installation\n\nYou can install this package using `pip`:\n\n```py\npip install torch_testing\n```\n\n## Usage example\n\nYou can assert the equality of two `torch.tensor`s like\n\n```py\nimport unittest\nimport torch\nimport torch_testing as tt\n\n\nclass TestSomeClass(unittest.TestCase):\n\n def test_some_method(self):\n a = torch.tensor([1, 2])\n b = torch.tensor([1, 2])\n tt.assert_equal(a, b)\n\nif __name__ == '__main__':\n unittest.main()\n```\n\n## Assertion methods\n\n### `assert_equal(actual, expected, **kwargs)`\nCurrently this assertion method is provided by converting the tensors to `numpy` arrays using `tensor.numpy()` and feeding them to [numpy.testing.assert_equal](https://docs.scipy.org/doc/numpy/reference/generated/numpy.testing.assert_equal.html#numpy.testing.assert_equal).\n\n### `assert_allclose(actual, expected, rtol=1e-07, atol=0, equal_nan=True, **kwargs)`\nCurrently this assertion method is provided by converting the tensors to `numpy` arrays using `tensor.numpy()` and feeding them to [numpy.testing.assert_allclose](https://docs.scipy.org/doc/numpy/reference/generated/numpy.testing.assert_allclose.html#numpy.testing.assert_allclose).\n\n### `assert_within(tensor, min_val, max_val, rtol=0)`\nEnsures that all values of the given `tensor` are greater than or equal to `min_val` and less than or equal to `max_val`. Allows to specify a relative tolerance `rtol`, which behaves as in [numpy.testing.assert_allclose](https://docs.scipy.org/doc/numpy/reference/generated/numpy.testing.assert_allclose.html#numpy.testing.assert_allclose).\n\n*NOTE: Uses `assert_allclose` under the hood, hence the fail message might currently be a little confusing.*\n\n## Development\n\n*Unless noted otherwise, all commands are expected to be executed from the root directory of this repository.*\n\n### Building the package for local development\n\nTo make the package available locally while making sure changes to the files are reflected immediately, run\n\n```sh\npip install -e .\n```\n\n### Test suite\n\nRun all tests using\n\n```sh\npython -m unittest discover tests\n```\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/the-bass/torch_testing", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "torch-testing", "package_url": "https://pypi.org/project/torch-testing/", "platform": "", "project_url": "https://pypi.org/project/torch-testing/", "project_urls": { "Homepage": "https://github.com/the-bass/torch_testing" }, "release_url": "https://pypi.org/project/torch-testing/0.0.2/", "requires_dist": null, "requires_python": "", "summary": "A collection of assertion methods to compare PyTorch Tensors in tests", "version": "0.0.2" }, "last_serial": 3912493, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "a3d0b4e04a16d1196ffe8e3c9e4058c7", "sha256": "b4c9e8141feb42a3f5a4ec2fae9f253573ee2bd1e2d21ac5e419dc7becc19af7" }, "downloads": -1, "filename": "torch_testing-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "a3d0b4e04a16d1196ffe8e3c9e4058c7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4763, "upload_time": "2018-05-30T10:35:13", "url": "https://files.pythonhosted.org/packages/11/1f/9d35b59db133502d8810bc5ca63313ad77fa48915fb11ddf28ae8e5dcb55/torch_testing-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0e8df35e1b03a682541051c2c330fe9f", "sha256": "17968ea06beaadcbc2362d2ebc6b392c8702d96ae672b470acd5d81c5a164eea" }, "downloads": -1, "filename": "torch_testing-0.0.1.tar.gz", "has_sig": false, "md5_digest": "0e8df35e1b03a682541051c2c330fe9f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2498, "upload_time": "2018-05-30T10:35:15", "url": "https://files.pythonhosted.org/packages/51/72/cee2758fab03644615e127f433a63774ad1b9802eefeb9b15ad41b949873/torch_testing-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "89dc303c78d3ae13095991fd21736acb", "sha256": "fba9a8db3b67c61630e6c8f539be6b63af81bd4d8561f8cda6ca4ef2270a5750" }, "downloads": -1, "filename": "torch_testing-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "89dc303c78d3ae13095991fd21736acb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4725, "upload_time": "2018-05-30T11:13:26", "url": "https://files.pythonhosted.org/packages/cf/fe/b3fa6a9400ef0b534bd6d0058247ec1dc4fbc70a6dc0b81bfd5bcb9c16b3/torch_testing-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b88de24af969db4b778a21fa0097948d", "sha256": "65fc4232ad4cba84da32e8054eb0fef8ba393633ba61d2be056c6c1d85869b35" }, "downloads": -1, "filename": "torch_testing-0.0.2.tar.gz", "has_sig": false, "md5_digest": "b88de24af969db4b778a21fa0097948d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2478, "upload_time": "2018-05-30T11:13:27", "url": "https://files.pythonhosted.org/packages/e5/85/8b5d7b8220fc483b329c81ea842d70535617098617333d112a156b0a0ca0/torch_testing-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "89dc303c78d3ae13095991fd21736acb", "sha256": "fba9a8db3b67c61630e6c8f539be6b63af81bd4d8561f8cda6ca4ef2270a5750" }, "downloads": -1, "filename": "torch_testing-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "89dc303c78d3ae13095991fd21736acb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4725, "upload_time": "2018-05-30T11:13:26", "url": "https://files.pythonhosted.org/packages/cf/fe/b3fa6a9400ef0b534bd6d0058247ec1dc4fbc70a6dc0b81bfd5bcb9c16b3/torch_testing-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b88de24af969db4b778a21fa0097948d", "sha256": "65fc4232ad4cba84da32e8054eb0fef8ba393633ba61d2be056c6c1d85869b35" }, "downloads": -1, "filename": "torch_testing-0.0.2.tar.gz", "has_sig": false, "md5_digest": "b88de24af969db4b778a21fa0097948d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2478, "upload_time": "2018-05-30T11:13:27", "url": "https://files.pythonhosted.org/packages/e5/85/8b5d7b8220fc483b329c81ea842d70535617098617333d112a156b0a0ca0/torch_testing-0.0.2.tar.gz" } ] }