{ "info": { "author": "Konrad Ja\u0142owiecki", "author_email": "dexter2206@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "[![Build Status](https://travis-ci.org/dexter2206/dimod-mock.svg?branch=master)](https://travis-ci.org/dexter2206/dimod-mock)\n\n# dimod-mock\n\ndimod-mock is a package for mocking dimod-based samplers, including the structured ones.\nIt lets you easily test your routines before trying them out on sophisticated samplers or real hardware.\n\n# Installation\n\nTo install run\n\n```\npip install dimodmock\n```\n\n# Usage\n\n## Mocking simple samplers\n\nSuppose you created some instance of your sampler (derived from `dimod.Sampler`). This is how you create its mock\n\n```python\nimport dimodmock\n\nsampler = ... # Create your sampler here\nmock = dimodmock.SamplerMock.from_sampler(sampler)\n```\n\nThe mock object created this way has the following properties identical to the source sampler\n- `properties`\n- `parameters`\n\nThe following methods are implemented:\n- `sample`\n- `sample_qubo`\n- `sample_ising`\n\nand have the same interface as the source sampler. In particular, call to those methods will fail\nif unknown parameters are passed as keyword arguments. The returned samples are choosen randomly at uniform.\nBy default, the returned samplesets have one sample. See below for overriding this behaviour.\n\n## Mocking structured samplers\n\nYou can also mock structured samplers. In this case use `dimodmock.StructuredMock.from_sampler`.\nIn addition to the characteristics described above, the `StructuredMock` has also the following properties, identical\nto the source sampler:\n- `edgelist`\n- `nodelist`\n\nAlso, `sample`, `sample_qubo`, `sample_ising` methods respect the samplers structure, so trying to solve\nmismatching instance will fail.\n\n## Support for `num_reads`\n\nBy default, samplesets returned by all mocks contain only one sample. However, if the source sampler supports `num_reads`\nproperty (which is true in particular for `DWaveSampler`), it will be respected by the mock and the correct number\nof samples will be returned.\n\n## Advanced usage\nIt is also possible to create mocks by specifying their properties in their initializer. For `SimpleMock` you need to specify \n`properties` and `parameters`. For `StructuredMock` you also need to specify `edgelist` and `nodelist`.\n\nFor instance, suppose you want to create a mock of a structured sampler defined on full graph of 3 nodes,\nhaving a `max_num_reads` property and `num_reads` parameter. Here is how to do it:\n\n```python\nfrom dimodmock import StructuredSampler\n\nmock = StructuredSampler(\n nodelist=[0, 1, 2], \n edgelist=[(0, 1), (1, 2), (2, 0)], \n properties={\"max_num_reads\": 10},\n parameters={\"num_reads\": [\"max_num_reads\"]},\n)\n```\n\n\n# Caveats\n\nCurrently mocks don't validate keyword arguments passed to `sample*` methods. \nSo, in the example above, mock will happily accept `num_reads=100`. In the future, additional validation might be\nimplemented.\n\n\n# Reporting issues\nPlease report any issues you encounter using Github's issue tracker.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "", "keywords": "dimod mock testing", "license": "", "maintainer": "", "maintainer_email": "", "name": "dimodmock", "package_url": "https://pypi.org/project/dimodmock/", "platform": "", "project_url": "https://pypi.org/project/dimodmock/", "project_urls": null, "release_url": "https://pypi.org/project/dimodmock/1.0.0/", "requires_dist": null, "requires_python": ">=3.6", "summary": "Utilities for mocking dimod Samplers", "version": "1.0.0" }, "last_serial": 5960856, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "51ea43fe1af1ca0a308bca212ae59e66", "sha256": "47a8f4c61487d1e20d8cf11b749423b8c02a865ebc2d7ed4a7155f0de4957b10" }, "downloads": -1, "filename": "dimodmock-1.0.0.tar.gz", "has_sig": false, "md5_digest": "51ea43fe1af1ca0a308bca212ae59e66", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 6691, "upload_time": "2019-10-11T15:27:41", "url": "https://files.pythonhosted.org/packages/a9/e9/6eab709cce4ad22393456e4308500dd903c66b2e0542a0d4de3e45034421/dimodmock-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "51ea43fe1af1ca0a308bca212ae59e66", "sha256": "47a8f4c61487d1e20d8cf11b749423b8c02a865ebc2d7ed4a7155f0de4957b10" }, "downloads": -1, "filename": "dimodmock-1.0.0.tar.gz", "has_sig": false, "md5_digest": "51ea43fe1af1ca0a308bca212ae59e66", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 6691, "upload_time": "2019-10-11T15:27:41", "url": "https://files.pythonhosted.org/packages/a9/e9/6eab709cce4ad22393456e4308500dd903c66b2e0542a0d4de3e45034421/dimodmock-1.0.0.tar.gz" } ] }