From be2902e77e0d1a2a07ddad981266de006baefdcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= Date: Tue, 18 Jul 2023 10:21:01 +0200 Subject: [PATCH] Add basic setup --- .gitignore | 129 ++++++++++ CODE_OF_CONDUCT.md | 9 + CONTRIBUTING.md | 340 +++++++++++++++++++++++++++ LICENSE.txt | 203 ++++++++++++++++ README.md | 57 +++++ constraints.txt | 2 + qiskit_algorithms/VERSION.txt | 1 + qiskit_algorithms/py.typed | 1 + qiskit_algorithms/utils/optionals.py | 26 ++ qiskit_algorithms/version.py | 84 +++++++ requirements-dev.txt | 18 ++ requirements.txt | 6 + setup.py | 77 ++++++ 13 files changed, 953 insertions(+) create mode 100644 .gitignore create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE.txt create mode 100644 README.md create mode 100644 constraints.txt create mode 100644 qiskit_algorithms/VERSION.txt create mode 100644 qiskit_algorithms/py.typed create mode 100644 qiskit_algorithms/utils/optionals.py create mode 100644 qiskit_algorithms/version.py create mode 100644 requirements-dev.txt create mode 100644 requirements.txt create mode 100644 setup.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..932137ae --- /dev/null +++ b/.gitignore @@ -0,0 +1,129 @@ +# MacOSX +.DS_Store + +# Dolphin KDE +.directory + +# editor files +.vscode/ +.idea/ + +# Standard python ignores follow + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so +*.so.dSYM +*.dll + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST +install/ + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ +.pytest_cache/ +test/**/*.log +test/**/*.pdf +test/**/*.prof +test/**/*.npz + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +.static_storage/ +.media/ +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +*/_build/ +docs/api/* +docs/stubs/* +docs/tutorials/data + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + +# stestr repostiory +.stestr/ diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..f82b61c5 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,9 @@ + + +# Code of Conduct +All members of this project agree to adhere to the Qiskit Code of Conduct listed at [https://github.com/Qiskit/qiskit/blob/master/CODE_OF_CONDUCT.md](https://github.com/Qiskit/qiskit/blob/master/CODE_OF_CONDUCT.md) + +---- + +License: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), +Copyright Contributors to Qiskit. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..345bb917 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,340 @@ +# Contributing + +**We appreciate all kinds of help, so thank you!** + +First please read the overall project contributing guidelines. These are +included in the Qiskit documentation here: + +https://qiskit.org/documentation/contributing_to_qiskit.html + +## Contributing to Qiskit Algorithms + +In addition to the general guidelines above there are specific details for +contributing to Qiskit Algorithms. + +You should first install the python development libraries by running +`pip install -r requirements-dev.txt` from the root of the +Machine Learning repository clone and then +follow the guidelines below. + +### Project Code Style. + +Code in Qiskit Algorithms should conform to PEP8 and style/lint checks are run to validate +this. Line length must be limited to no more than 100 characters. Docstrings +should be written using the Google docstring format. + +### Pull request checklist + +When submitting a pull request and you feel it is ready for review, +please ensure that: + +1. The code follows the _code style_ of this project and successfully + passes the _unit tests_. Qiskit Algorithms uses [Pylint](https://www.pylint.org) and + [PEP8](https://www.python.org/dev/peps/pep-0008) style guidelines. + + You can run + ```shell script + make lint + make style + ``` + from the root of the Algorithms repository clone for lint and style conformance checks. + + If your code fails the local style checks (specifically the black + code formatting check) you can use `make black` to automatically + fix update the code formatting. + + For unit testing please see [Testing](#testing) section below. + +2. The documentation has been updated accordingly. In particular, if a + function or class has been modified during the PR, please update the + *docstring* accordingly. + + The documentation will be built/tested using Sphinx and should be free + from errors and warnings. + You will need to [install pandoc](https://pandoc.org/installing.html) first. + + Then you can run + ```shell script + make html + ``` + from the root of the Algorithms repository clone. You might also like to check the html output + to see the changes formatted output is as expected. You will find an index.html + file in docs\_build\html and you can navigate from there. + + Please note that a spell check is run in CI, on the docstrings, since the text + becomes part of the online [API Documentation](https://qiskit.org/documentation/). + + You can run `make spell` locally to check spelling though you would need to + [install pyenchant](https://pyenchant.github.io/pyenchant/install.html) and be using + hunspell-en-us as is used by the CI. + + For some words, such as names, technical terms, referring to parameters of the method etc., + that are not in the en-us dictionary and get flagged as being misspelled, despite being correct, + there is a [.pylintdict](./.pylintdict) custom word list file, in the root of the Machine Learning repo, + where such words can be added, in alphabetic order, as needed. + +3. If it makes sense for your change that you have added new tests that + cover the changes and any new function. + +4. Ensure that if your change has an end user facing impact (new feature, + deprecation, removal etc) that you have added a reno release note for + that change and that the PR is tagged for the changelog. + +5. Ensure all code, including unit tests, has the copyright header. The copyright + date will be checked by CI build. The format of the date(s) is _year of creation, + last year changed_. So for example: + + > \# (C) Copyright IBM 2018, 2021. + + If the _year of creation_ is the same as _last year changed_ then only + one date is needed, for example: + + > \# (C) Copyright IBM 2021. + + If code is changed in a file make sure the copyright includes the current year. + If there is just one date and it's a prior year then add the current year as the 2nd date, + otherwise simply change the 2nd date to the current year. The _year of creation_ date is + never changed. + +### Changelog generation + +The changelog is automatically generated as part of the release process +automation. This works through a combination of the git log and the pull +request. When a release is tagged and pushed to github the release automation +bot looks at all commit messages from the git log for the release. It takes the +PR numbers from the git log (assuming a squash merge) and checks if that PR had +a `Changelog:` label on it. If there is a label it will add the git commit +message summary line from the git log for the release to the changelog. + +If there are multiple `Changelog:` tags on a PR the git commit message summary +line from the git log will be used for each changelog category tagged. + +The current categories for each label are as follows: + +| PR Label | Changelog Category | +| -----------------------|--------------------| +| Changelog: Deprecation | Deprecated | +| Changelog: New Feature | Added | +| Changelog: API Change | Changed | +| Changelog: Removal | Removed | +| Changelog: Bugfix | Fixed | + +### Release Notes + +When making any end user facing changes in a contribution we have to make sure +we document that when we release a new version of qiskit-machine-learning. The expectation +is that if your code contribution has user facing changes that you will write +the release documentation for these changes. This documentation must explain +what was changed, why it was changed, and how users can either use or adapt +to the change. The idea behind release documentation is that when a naive +user with limited internal knowledge of the project is upgrading from the +previous release to the new one, they should be able to read the release notes, +understand if they need to update their program which uses qiskit, and how they +would go about doing that. It ideally should explain why they need to make +this change too, to provide the necessary context. + +To make sure we don't forget a release note or if the details of user facing +changes over a release cycle we require that all user facing changes include +documentation at the same time as the code. To accomplish this we use the +[reno](https://docs.openstack.org/reno/latest/) tool which enables a git based +workflow for writing and compiling release notes. + +#### Adding a new release note + +Making a new release note is quite straightforward. Ensure that you have reno +installed with:: + + pip install -U reno + +Once you have reno installed you can make a new release note by running in +your local repository checkout's root:: + + reno new short-description-string + +where short-description-string is a brief string (with no spaces) that describes +what's in the release note. This will become the prefix for the release note +file. Once that is run it will create a new yaml file in releasenotes/notes. +Then open that yaml file in a text editor and write the release note. The basic +structure of a release note is restructured text in yaml lists under category +keys. You add individual items under each category and they will be grouped +automatically by release when the release notes are compiled. A single file +can have as many entries in it as needed, but to avoid potential conflicts +you'll want to create a new file for each pull request that has user facing +changes. When you open the newly created file it will be a full template of +the different categories with a description of a category as a single entry +in each category. You'll want to delete all the sections you aren't using and +update the contents for those you are. For example, the end result should +look something like:: + +```yaml +features: + - | + Introduced a new feature foo, that adds support for doing something to + ``QuantumCircuit`` objects. It can be used by using the foo function, + for example:: + + from qiskit import foo + from qiskit import QuantumCircuit + foo(QuantumCircuit()) + + - | + The ``qiskit.QuantumCircuit`` module has a new method ``foo()``. This is + the equivalent of calling the ``qiskit.foo()`` to do something to your + QuantumCircuit. This is the equivalent of running ``qiskit.foo()`` on + your circuit, but provides the convenience of running it natively on + an object. For example:: + + from qiskit import QuantumCircuit + + circ = QuantumCircuit() + circ.foo() + +deprecations: + - | + The ``qiskit.bar`` module has been deprecated and will be removed in a + future release. Its sole function, ``foobar()`` has been superseded by the + ``qiskit.foo()`` function which provides similar functionality but with + more accurate results and better performance. You should update your calls + ``qiskit.bar.foobar()`` calls to ``qiskit.foo()``. +``` + +You can also look at other release notes for other examples. + +You can use any restructured text feature in them (code sections, tables, +enumerated lists, bulleted list, etc) to express what is being changed as +needed. In general you want the release notes to include as much detail as +needed so that users will understand what has changed, why it changed, and how +they'll have to update their code. + +After you've finished writing your release notes you'll want to add the note +file to your commit with `git add` and commit them to your PR branch to make +sure they're included with the code in your PR. + +#### Generating the release notes + +After release notes have been added if you want to see what the full output of +the release notes. In general the output from reno that we'll get is a rst +(ReStructuredText) file that can be compiled by +[sphinx](https://www.sphinx-doc.org/en/master/). To generate the rst file you +use the ``reno report`` command. If you want to generate the full Algorithms release +notes for all releases (since we started using reno during 0.9) you just run:: + + reno report + +but you can also use the ``--version`` argument to view a single release (after +it has been tagged:: + + reno report --version 0.5.0 + +At release time ``reno report`` is used to generate the release notes for the +release and the output will be submitted as a pull request to the documentation +repository's [release notes file]( +https://github.com/Qiskit/qiskit/blob/main/docs/release_notes.rst) + +#### Building release notes locally + +Building The release notes are part of the standard qiskit-algorithms documentation +builds. To check what the rendered html output of the release notes will look +like for the current state of the repo you can run: `tox -edocs` which will +build all the documentation into `docs/_build/html` and the release notes in +particular will be located at `docs/_build/html/release_notes.html` + +## Installing Qiskit Algorithms from source + +Please see the [Installing Qiskit Algorithms from +Source](https://github.com/qiskit-community/qiskit-algorithms#installation) +section of the Qiskit documentation. + +Note: Qiskit Algorithms depends on Terra, and has optional dependence on Aer, so +these should be installed too. The main branch of Algorithms is kept working with those other element +main branches so these should be installed from source too following the instructions at +the same location + +Algorithms also has some other optional dependents see +[Algorithms optional installs](https://github.com/qiskit-community/qiskit-algorithms#optional-installs) for +further information. Unit tests that require any of the optional dependents will check +and skip the test if not installed. + +### Testing + +Once you've made a code change, it is important to verify that your change +does not break any existing tests and that any new tests that you've added +also run successfully. Before you open a new pull request for your change, +you'll want to run the test suite locally. + +The test suite can be run from a command line or via your IDE. You can run `make test` which will +run all unit tests. Another way to run the test suite is to use +[**tox**](https://tox.readthedocs.io/en/latest/#). For more information about using tox please +refer to +[Terra CONTRIBUTING](https://github.com/Qiskit/qiskit-terra/blob/main/CONTRIBUTING.md#test) +Test section. However please note Algorithms does not have any +[online tests](https://github.com/Qiskit/qiskit-terra/blob/main/CONTRIBUTING.md#online-tests) +nor does it have +[test skip + options](https://github.com/Qiskit/qiskit-terra/blob/main/CONTRIBUTING.md#test-skip-options). + +### Development Cycle + +The development cycle for qiskit-algorithms is informed by release plans in the +[Qiskit rfcs repository](https://github.com/Qiskit/rfcs) + +### Branches + +* `main`: + +The main branch is used for development of the next version of qiskit-algorithms. +It will be updated frequently and should not be considered stable. The API +can and will change on main as we introduce and refine new features. + +* `stable/*`: +The stable branches are used to maintain the most recent released versions of +qiskit-machine-learning. It contains the versions of the code corresponding to the minor +version release in the branch name release for The API on these branches are +stable and the only changes merged to it are bugfixes. + +### Release Cycle + +From time to time, we will release brand new versions of Qiskit Algorithms. These +are well-tested versions of the software. + +When the time for a new release has come, we will: + +1. Create a new tag with the version number and push it to github +2. Change the `main` version to the next release version. + +The release automation processes will be triggered by the new tag and perform +the following steps: + +1. Create a stable branch for the new minor version from the release tag + on the `main` branch +2. Build and upload binary wheels to pypi +3. Create a github release page with a generated changelog +4. Generate a PR on the meta-repository to bump the terra version and + meta-package version. + +The `stable/*` branches should only receive changes in the form of bug +fixes. + +## Dealing with the git blame ignore list + +In the qiskit-algorithms repository we maintain a list of commits for git blame +to ignore. This is mostly commits that are code style changes that don't +change the functionality but just change the code formatting (for example, +when we migrated to use black for code formatting). This file, +`.git-blame-ignore-revs` just contains a list of commit SHA1s you can tell git +to ignore when using the `git blame` command. This can be done one time +with something like + +``` +git blame --ignore-revs-file .git-blame-ignore-revs qiskit_algorithms/version.py +``` + +from the root of the repository. If you'd like to enable this by default you +can update your local repository's configuration with: + +``` +git config blame.ignoreRevsFile .git-blame-ignore-revs +``` + +which will update your local repositories configuration to use the ignore list +by default. diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 00000000..5333c633 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,203 @@ + Copyright 2017 IBM and its contributors + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2017 IBM and its contributors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 00000000..1fcf31f9 --- /dev/null +++ b/README.md @@ -0,0 +1,57 @@ +# Qiskit Algorithms + +[TODO: Add license] + +## Installation + +We encourage installing Qiskit Algorithms via the pip tool (a python package manager). + +```bash +pip install qiskit-algorithms +``` + +**pip** will handle all dependencies automatically and you will always install the latest +(and well-tested) version. + +If you want to work on the very latest work-in-progress versions, either to try features ahead of +their official release or if you want to contribute to Algorithms, then you can install from source. +To do this follow the instructions in the + [documentation](https://qiskit.org/ecosystem/algorithms/getting_started.html#installation). + + +---------------------------------------------------------------------------------------------------- + +### Optional Installs + +### Creating Your First Algorithm in Qiskit + + +### Further examples + + +---------------------------------------------------------------------------------------------------- + +## Contribution Guidelines + +If you'd like to contribute to Qiskit, please take a look at our +[contribution guidelines](https://github.com/qiskit-community/qiskit-algorithms/blob/main/CONTRIBUTING.md). +This project adheres to Qiskit's [code of conduct](https://github.com/qiskit-community/qiskit-algorithms/blob/main/CODE_OF_CONDUCT.md). +By participating, you are expected to uphold this code. + +We use [GitHub issues](https://github.com/qiskit-community/qiskit-algorithms/issues) for tracking requests and bugs. Please +[join the Qiskit Slack community](https://qisk.it/join-slack) +and for discussion and simple questions. +For questions that are more suited for a forum, we use the **Qiskit** tag in [Stack Overflow](https://stackoverflow.com/questions/tagged/qiskit). + +## Authors and Citation + +Qiskit Algorithms was inspired, authored and brought about by the collective work of a team of researchers. +Algorithms continues to grow with the help and work of +[many people](https://github.com/qiskit-community/qiskit-algorithms/graphs/contributors), who contribute +to the project at different levels. +If you use Qiskit, please cite as per the provided +[BibTeX file](https://github.com/Qiskit/qiskit/blob/master/Qiskit.bib). + +## License + +This project uses the [Apache License 2.0](https://github.com/qiskit-community/qiskit-algorithms/blob/main/LICENSE.txt). diff --git a/constraints.txt b/constraints.txt new file mode 100644 index 00000000..b1d25275 --- /dev/null +++ b/constraints.txt @@ -0,0 +1,2 @@ +numpy>=1.20.0 +ipython<8.13;python_version<'3.9' diff --git a/qiskit_algorithms/VERSION.txt b/qiskit_algorithms/VERSION.txt new file mode 100644 index 00000000..6e8bf73a --- /dev/null +++ b/qiskit_algorithms/VERSION.txt @@ -0,0 +1 @@ +0.1.0 diff --git a/qiskit_algorithms/py.typed b/qiskit_algorithms/py.typed new file mode 100644 index 00000000..1242d432 --- /dev/null +++ b/qiskit_algorithms/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. diff --git a/qiskit_algorithms/utils/optionals.py b/qiskit_algorithms/utils/optionals.py new file mode 100644 index 00000000..e3dd2db4 --- /dev/null +++ b/qiskit_algorithms/utils/optionals.py @@ -0,0 +1,26 @@ +# This code is part of Qiskit. +# +# (C) Copyright IBM 2022. +# +# This code is licensed under the Apache License, Version 2.0. You may +# obtain a copy of this license in the LICENSE.txt file in the root directory +# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. +# +# Any modifications or derivative works of this code must retain this +# copyright notice, and modified files need to carry a notice indicating +# that they have been altered from the originals. + +""" +Additional optional constants. +""" + +from qiskit.utils import LazyImportTester + + +HAS_NLOPT = LazyImportTester("nlopt", name="NLopt Optimizer", install="pip install nlopt") +HAS_SKQUANT = LazyImportTester( + "skquant.opt", + name="scikit-quant", + install="pip install scikit-quant", +) +HAS_SQSNOBFIT = LazyImportTester("SQSnobFit", install="pip install SQSnobFit") diff --git a/qiskit_algorithms/version.py b/qiskit_algorithms/version.py new file mode 100644 index 00000000..10039681 --- /dev/null +++ b/qiskit_algorithms/version.py @@ -0,0 +1,84 @@ +# This code is part of Qiskit. +# +# (C) Copyright IBM 2019, 2021. +# +# This code is licensed under the Apache License, Version 2.0. You may +# obtain a copy of this license in the LICENSE.txt file in the root directory +# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. +# +# Any modifications or derivative works of this code must retain this +# copyright notice, and modified files need to carry a notice indicating +# that they have been altered from the originals. + +"""Contains the Algorithms version.""" + +import os +import subprocess + +ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) +QISKIT_DIR = os.path.dirname(ROOT_DIR) + + +def _minimal_ext_cmd(cmd): + # construct minimal environment + env = {} + for k in ["SYSTEMROOT", "PATH"]: + v = os.environ.get(k) + if v is not None: + env[k] = v + # LANGUAGE is used on win32 + env["LANGUAGE"] = "C" + env["LANG"] = "C" + env["LC_ALL"] = "C" + with subprocess.Popen( + cmd, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + env=env, + cwd=os.path.join(os.path.dirname(QISKIT_DIR)), + ) as proc: + stdout, stderr = proc.communicate() + if proc.returncode > 0: + raise OSError( + f"Command {cmd} exited with code {proc.returncode}: {stderr.strip().decode('ascii')}" + ) + return stdout + + +def git_version(): + """Get the current git head sha1.""" + # Determine if we're at main + try: + out = _minimal_ext_cmd(["git", "rev-parse", "HEAD"]) + git_revision = out.strip().decode("ascii") + except OSError: + git_revision = "Unknown" + + return git_revision + + +with open(os.path.join(ROOT_DIR, "VERSION.txt"), "r", encoding="utf8") as version_file: + VERSION = version_file.read().strip() + + +def get_version_info(): + """Get the full version string.""" + # Adding the git rev number needs to be done inside + # write_version_py(), otherwise the import of scipy.version messes + # up the build under Python 3. + full_version = VERSION + + if not os.path.exists(os.path.join(os.path.dirname(QISKIT_DIR), ".git")): + return full_version + try: + release = _minimal_ext_cmd(["git", "tag", "-l", "--points-at", "HEAD"]) + except Exception: # pylint: disable=broad-except + return full_version + git_revision = git_version() + if not release: + full_version += ".dev0+" + git_revision[:7] + + return full_version + + +__version__ = get_version_info() diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 00000000..6240e068 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,18 @@ +coverage>=4.4.0 +matplotlib>=2.1 +black[jupyter]~=22.0 +pylint>=2.15.0 +pylatexenc>=1.4 +stestr>=2.0.0 +ddt>=1.2.0,!=1.4.0 +reno>=3.4.0 +Sphinx>=5.0 +sphinx-design>=0.4.0 +sphinxcontrib-spelling +jupyter-sphinx +discover +qiskit-aer>=0.11.2 +mypy>=0.981 +mypy-extensions>=0.4.3 +nbsphinx +qiskit_sphinx_theme~=1.12.0 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..c09b7b95 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +qiskit-terra>=0.24 +scipy>=1.4 +numpy>=1.17 +psutil>=5 +fastdtw +setuptools>=40.1.0 diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..510453d0 --- /dev/null +++ b/setup.py @@ -0,0 +1,77 @@ +# This code is part of Qiskit. +# +# (C) Copyright IBM 2021, 2023. +# +# This code is licensed under the Apache License, Version 2.0. You may +# obtain a copy of this license in the LICENSE.txt file in the root directory +# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. +# +# Any modifications or derivative works of this code must retain this +# copyright notice, and modified files need to carry a notice indicating +# that they have been altered from the originals. + +import setuptools +import inspect +import sys +import os +import re + +with open('requirements.txt') as f: + REQUIREMENTS = f.read().splitlines() + +if not hasattr(setuptools, 'find_namespace_packages') or not inspect.ismethod(setuptools.find_namespace_packages): + print("Your setuptools version:'{}' does not support PEP 420 (find_namespace_packages). " + "Upgrade it to version >='40.1.0' and repeat install.".format(setuptools.__version__)) + sys.exit(1) + +VERSION_PATH = os.path.join(os.path.dirname(__file__), "qiskit_algorithms", "VERSION.txt") +with open(VERSION_PATH, "r") as version_file: + VERSION = version_file.read().strip() + +# Read long description from README. +README_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)), "README.md") +with open(README_PATH) as readme_file: + README = re.sub( + ".*", + "", + readme_file.read(), + flags=re.S | re.M, + ) + +setuptools.setup( + name='qiskit-algorithms', + version=VERSION, + description='Qiskit Algorithms: A library of quantum computing algorithms', + long_description=README, + long_description_content_type="text/markdown", + url='https://github.com/qiskit-community/qiskit-algorithms', + author='Qiskit Algorithms Development Team', + author_email='hello@qiskit.org', + license='Apache-2.0', + classifiers=[ + "Environment :: Console", + "License :: OSI Approved :: Apache Software License", + "Intended Audience :: Developers", + "Intended Audience :: Science/Research", + "Operating System :: Microsoft :: Windows", + "Operating System :: MacOS", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Topic :: Scientific/Engineering" + ], + keywords='qiskit sdk quantum algorithms', + packages=setuptools.find_packages(include=['qiskit_algorithms','qiskit_algorithms.*']), + install_requires=REQUIREMENTS, + include_package_data=True, + python_requires=">=3.8", + project_urls={ + "Bug Tracker": "https://github.com/qiskit-community/qiskit-algorithms/issues", + "Documentation": "https://qiskit.org/ecosystem/algorithms/", + "Source Code": "https://github.com/qiskit-community/qiskit-algorithms", + }, + zip_safe=False +)