Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/apache/mahout
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmusselman committed Mar 13, 2024
2 parents 9c20b1a + b88387d commit 6ddca38
Show file tree
Hide file tree
Showing 10 changed files with 273 additions and 20 deletions.
265 changes: 265 additions & 0 deletions examples/Simple_Example.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,265 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"authorship_tag": "ABX9TyNiuKjMe3+6/4/lQ29BvXn0",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/rawkintrevo/mahout/blob/mahout-2198/examples/Simple_Example.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"source": [
"!pip install git+https://github.com/apache/mahout.git@main\n"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "lNDTZhztd2dp",
"outputId": "ea3b9e41-43a8-44e7-9daf-e62e71d93143"
},
"execution_count": 1,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Collecting git+https://github.com/apache/mahout.git@main\n",
" Cloning https://github.com/apache/mahout.git (to revision main) to /tmp/pip-req-build-hjfu63k9\n",
" Running command git clone --filter=blob:none --quiet https://github.com/apache/mahout.git /tmp/pip-req-build-hjfu63k9\n",
" Resolved https://github.com/apache/mahout.git to commit 9ca93e01bf6ad9e87ef302917c740412ed6428b2\n",
" Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n",
" Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n",
" Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
"Collecting qiskit<0.46.0,>=0.45.1 (from qumat==0.0.1)\n",
" Downloading qiskit-0.45.3-py3-none-any.whl (9.6 kB)\n",
"Collecting qiskit-aer<0.14.0,>=0.13.2 (from qumat==0.0.1)\n",
" Downloading qiskit_aer-0.13.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.3 MB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m12.3/12.3 MB\u001b[0m \u001b[31m26.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hCollecting qiskit-terra==0.45.3 (from qiskit<0.46.0,>=0.45.1->qumat==0.0.1)\n",
" Downloading qiskit_terra-0.45.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.3 MB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m6.3/6.3 MB\u001b[0m \u001b[31m47.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hCollecting rustworkx>=0.13.0 (from qiskit-terra==0.45.3->qiskit<0.46.0,>=0.45.1->qumat==0.0.1)\n",
" Downloading rustworkx-0.14.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.1 MB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.1/2.1 MB\u001b[0m \u001b[31m55.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hRequirement already satisfied: numpy<2,>=1.17 in /usr/local/lib/python3.10/dist-packages (from qiskit-terra==0.45.3->qiskit<0.46.0,>=0.45.1->qumat==0.0.1) (1.25.2)\n",
"Collecting ply>=3.10 (from qiskit-terra==0.45.3->qiskit<0.46.0,>=0.45.1->qumat==0.0.1)\n",
" Downloading ply-3.11-py2.py3-none-any.whl (49 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m49.6/49.6 kB\u001b[0m \u001b[31m4.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hRequirement already satisfied: psutil>=5 in /usr/local/lib/python3.10/dist-packages (from qiskit-terra==0.45.3->qiskit<0.46.0,>=0.45.1->qumat==0.0.1) (5.9.5)\n",
"Requirement already satisfied: scipy>=1.5 in /usr/local/lib/python3.10/dist-packages (from qiskit-terra==0.45.3->qiskit<0.46.0,>=0.45.1->qumat==0.0.1) (1.11.4)\n",
"Requirement already satisfied: sympy>=1.3 in /usr/local/lib/python3.10/dist-packages (from qiskit-terra==0.45.3->qiskit<0.46.0,>=0.45.1->qumat==0.0.1) (1.12)\n",
"Collecting dill>=0.3 (from qiskit-terra==0.45.3->qiskit<0.46.0,>=0.45.1->qumat==0.0.1)\n",
" Downloading dill-0.3.8-py3-none-any.whl (116 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m116.3/116.3 kB\u001b[0m \u001b[31m12.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hRequirement already satisfied: python-dateutil>=2.8.0 in /usr/local/lib/python3.10/dist-packages (from qiskit-terra==0.45.3->qiskit<0.46.0,>=0.45.1->qumat==0.0.1) (2.8.2)\n",
"Collecting stevedore>=3.0.0 (from qiskit-terra==0.45.3->qiskit<0.46.0,>=0.45.1->qumat==0.0.1)\n",
" Downloading stevedore-5.2.0-py3-none-any.whl (49 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m49.7/49.7 kB\u001b[0m \u001b[31m5.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hCollecting symengine!=0.10.0,>=0.9 (from qiskit-terra==0.45.3->qiskit<0.46.0,>=0.45.1->qumat==0.0.1)\n",
" Downloading symengine-0.11.0-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (39.4 MB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m39.4/39.4 MB\u001b[0m \u001b[31m14.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hRequirement already satisfied: typing-extensions in /usr/local/lib/python3.10/dist-packages (from qiskit-terra==0.45.3->qiskit<0.46.0,>=0.45.1->qumat==0.0.1) (4.10.0)\n",
"Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil>=2.8.0->qiskit-terra==0.45.3->qiskit<0.46.0,>=0.45.1->qumat==0.0.1) (1.16.0)\n",
"Collecting pbr!=2.1.0,>=2.0.0 (from stevedore>=3.0.0->qiskit-terra==0.45.3->qiskit<0.46.0,>=0.45.1->qumat==0.0.1)\n",
" Downloading pbr-6.0.0-py2.py3-none-any.whl (107 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m107.5/107.5 kB\u001b[0m \u001b[31m10.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
"\u001b[?25hRequirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.10/dist-packages (from sympy>=1.3->qiskit-terra==0.45.3->qiskit<0.46.0,>=0.45.1->qumat==0.0.1) (1.3.0)\n",
"Building wheels for collected packages: qumat\n",
" Building wheel for qumat (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for qumat: filename=qumat-0.0.1-py3-none-any.whl size=9957 sha256=a7ffe71a3aecd914a49905829bec86f9691eafac6af8500a110b1ee5257d4bbd\n",
" Stored in directory: /tmp/pip-ephem-wheel-cache-fy8zfa_b/wheels/5a/92/df/8057f1db19a8a1d231017beafd367b718fa3be68bf0ef9cb70\n",
"Successfully built qumat\n",
"Installing collected packages: ply, symengine, rustworkx, pbr, dill, stevedore, qiskit-terra, qiskit, qiskit-aer, qumat\n",
"Successfully installed dill-0.3.8 pbr-6.0.0 ply-3.11 qiskit-0.45.3 qiskit-aer-0.13.3 qiskit-terra-0.45.3 qumat-0.0.1 rustworkx-0.14.1 stevedore-5.2.0 symengine-0.11.0\n"
]
}
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"id": "M3O-QEdbd1Y2"
},
"outputs": [],
"source": [
"# Import the QuantumComputer class from your package\n",
"from qumat.qumat import QuMat\n",
"\n"
]
},
{
"cell_type": "code",
"source": [
"# Create an instance of QuantumComputer with a specific backend configuration\n",
"backend_config = {\n",
" 'backend_name': 'qiskit_simulator', # Replace with the actual backend you want to use\n",
" 'backend_options': {\n",
" 'simulator_type': 'aer_simulator',\n",
" 'shots': 1024 # Number of shots for measurement\n",
" }\n",
"}\n",
"qumat = QuMat(backend_config)\n",
"\n",
"# Create a quantum circuit\n",
"qumat.create_empty_circuit(num_qubits=2)\n",
"\n",
"# Apply quantum gates to the circuit\n",
"qumat.apply_hadamard_gate(qubit_index=0)\n",
"qumat.apply_cnot_gate(control_qubit_index=0, target_qubit_index=1)\n",
"qumat.apply_pauli_x_gate(qubit_index=0)\n"
],
"metadata": {
"id": "56zR0RS4eNuY"
},
"execution_count": 9,
"outputs": []
},
{
"cell_type": "code",
"source": [
"\n",
"# Measure the quantum circuit\n",
"measurement_results = qumat.circuit.measure_all()"
],
"metadata": {
"id": "1FaC7deljh5I"
},
"execution_count": 10,
"outputs": []
},
{
"cell_type": "code",
"source": [
"# Display the measurement results\n",
"print(\"Measurement Results:\", measurement_results)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "YEOzZJzXjPsU",
"outputId": "6ffd7923-f93e-4858-a280-8f40a79ab468"
},
"execution_count": 14,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Measurement Results: None\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"#qiskit object method\n",
"qumat.circuit.draw()"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 156
},
"id": "Mz8gUmf3etu7",
"outputId": "917d37bb-10bc-443b-9b7d-ff83ee8e16ac"
},
"execution_count": 15,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" ┌───┐ ┌───┐ ░ ┌─┐ ░ ┌─┐ \n",
" q_0: ┤ H ├──■──┤ X ├─░─┤M├────░─┤M├───\n",
" └───┘┌─┴─┐└───┘ ░ └╥┘┌─┐ ░ └╥┘┌─┐\n",
" q_1: ─────┤ X ├──────░──╫─┤M├─░──╫─┤M├\n",
" └───┘ ░ ║ └╥┘ ░ ║ └╥┘\n",
" meas: 2/═══════════════════╩══╩═════╬══╬═\n",
" 0 1 ║ ║ \n",
"meas0: 2/════════════════════════════╩══╩═\n",
" 0 1 "
],
"text/html": [
"<pre style=\"word-wrap: normal;white-space: pre;background: #fff0;line-height: 1.1;font-family: &quot;Courier New&quot;,Courier,monospace\"> ┌───┐ ┌───┐ ░ ┌─┐ ░ ┌─┐ \n",
" q_0: ┤ H ├──■──┤ X ├─░─┤M├────░─┤M├───\n",
" └───┘┌─┴─┐└───┘ ░ └╥┘┌─┐ ░ └╥┘┌─┐\n",
" q_1: ─────┤ X ├──────░──╫─┤M├─░──╫─┤M├\n",
" └───┘ ░ ║ └╥┘ ░ ║ └╥┘\n",
" meas: 2/═══════════════════╩══╩═════╬══╬═\n",
" 0 1 ║ ║ \n",
"meas0: 2/════════════════════════════╩══╩═\n",
" 0 1 </pre>"
]
},
"metadata": {},
"execution_count": 15
}
]
},
{
"cell_type": "code",
"source": [
"# Also requires qiskit\n",
"from qiskit import execute\n",
"# needs to be added as a method...\n",
"job = execute(qumat.circuit, qumat.backend, shots=1024) # Simulate the circuit 1024 times\n",
"\n",
"\n",
"result = job.result()\n",
"counts = result.get_counts()\n",
"\n",
"print(\"Measurement Results:\", counts)"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "HrhrQVIEjrzz",
"outputId": "25c993a7-b894-4a9b-96a3-7fe9aead9422"
},
"execution_count": 16,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Measurement Results: {'10 10': 503, '01 01': 521}\n"
]
}
]
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "jVBuEr2EleH1"
},
"execution_count": null,
"outputs": []
}
]
}
3 changes: 1 addition & 2 deletions qumat/qumat.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ def __init__(self, backend_config):
self.backend_config = backend_config
# Initialize the quantum backend (Qiskit, Cirq, Bracket, etc.) based on
# the config
self.backend = qiskit.Aer.get_backend(backend_config['backend_name'])
self.backend = self._initialize_backend()
self.backend_name = backend_config['backend_name']
self.backend = self._initialize_backend()
# Initialize an empty quantum circuit
self.circuit = None

Expand Down
3 changes: 0 additions & 3 deletions website/_includes/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@
href="/documentation/developers/">Developer Documentation</a>
<a class="dropdown-item"
href="/community/coc.html">Code of Conduct</a>
<a class="dropdown-item"
href="/404.html">Partners and Supporters</a>
<!-- Maybe make a new page that merges professional support and powered-by-mahout?-->
</div>
</li>

Expand Down
2 changes: 1 addition & 1 deletion website/about/how-to-contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ First of all, you need to get the [Mahout source code](/developers/version-contr
<a name="HowToContribute-MakingChanges"></a>
## Making Changes

Before you start, you should send a message to the [Mahout developer mailing list](/general/mailing-lists,-irc-and-archives.html)
Before you start, you should send a message to the [Mahout developer mailing list](/community/mailing-lists.html)
(note: you have to subscribe before you can post), or file a ticket in our [issue tracker](/developers/issue-tracker.html).
Describe your proposed changes and check that they fit in with what others are doing and have planned for the project. Be patient, it may take folks a while to understand your requirements.

Expand Down
6 changes: 0 additions & 6 deletions website/community/mailing-lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ committed.
* [http://mail-archives.apache.org/mod_mbox/mahout-dev/](http://mail-archives.apache.org/mod_mbox/mahout-dev/)
* [http://mail-archives.apache.org/mod_mbox/mahout-user/](http://mail-archives.apache.org/mod_mbox/mahout-user/)

<a name="MailingLists,IRCandArchives-ExternalArchives"></a>
## External Archives

* [MarkMail](http://mahout.markmail.org/)
* [Gmane](http://dir.gmane.org/gmane.comp.apache.mahout.user)

Please note the inclusion of a link to an archive does not imply an
endorsement of that company by any of the committers of Mahout the Lucene
PMC or the Apache Software Foundation. Each archive owner is solely
Expand Down
2 changes: 1 addition & 1 deletion website/documentation/developers/developer-resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ All bugs, improvements, [pull requests](http://mahout.apache.org/developers/gith
<a name="DeveloperResources-ContinuousIntegration"></a>
## Continuous Integration

Mahout is continuously built on an hourly basis on the [Apache Jenkins](https://builds.apache.org/job/Mahout-Quality/) build system.
Mahout is continuously built using [Apache Maven](https://github.com/apache/mahout/actions/workflows/mahout.yml).

## Board reports

Expand Down
2 changes: 1 addition & 1 deletion website/documentation/developers/gsoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ your career.
## References

* [GSoC Home](http://code.google.com/soc/) - official GSoC page
* [GSoC FAQ](http://socghop.appspot.com/document/show/gsoc_program/google/gsoc2010/faqs) - official FAQ
* [GSoC FAQ](https://developers.google.com/open-source/gsoc/faq) - official FAQ
* [Apache GSoC coordination](http://community.apache.org/gsoc.html) - official Apache GSoC documentation, especially important if you want to become a mentor
4 changes: 2 additions & 2 deletions website/documentation/developers/how-to-update-the-website.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Committers and contributors are all welcomed and encouraged to update the Mahout

```git clone http://github.com/apache/mahout```

See [Building from Source](/developers/buildingmahout/#getting-code) for more details.
See [Building from Source](/developers/buildingmahout.html#getting-code) for more details.

#### Working with Markdown

Expand Down Expand Up @@ -48,7 +48,7 @@ open your favorite browser and make sure your changes look the way you expect th
#### Commit code and open a PR

Once you're sure everything is right, you commit your code, push to your github.com account (preferably on a branch other than `trunk`
then click "OpenPR"). This process closely follows [How To Contribute- Making Changes](/developers/how-to-contribute/#HowToContribute-MakingChanges) with an exception that for _WEBSITE ONLY_ changes we relax the requirement to open a JIRA ticket. That is to say, small
then click "OpenPR"). This process closely follows [How To Contribute- Making Changes](/developers/how-to-contribute.html#HowToContribute-MakingChanges) with an exception that for _WEBSITE ONLY_ changes we relax the requirement to open a JIRA ticket. That is to say, small
website changes such as fixing a broken link or typo, do not require a specific JIRA issues, and where you would normally
commit with a message like `MAHOUT-XXXX The thing I did` (where `XXXX` is the assosciated JIRA number), you can instead
simply create a message like `WEBSITE Typos in how-to-update-the-website.md`. There's nothing to stop you from making a
Expand Down
4 changes: 1 addition & 3 deletions website/documentation/developers/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ By following this Developer's Guide, developers can quickly harness the power of

[Developer Resources](/developers/developer-resources.html)

[Index](/developers/index.html)

[Githubprs](/developers/githubPRs.html)

[Buildingmahout](/developers/buildingmahout.html)
Expand All @@ -55,4 +53,4 @@ By following this Developer's Guide, developers can quickly harness the power of

[Issue Tracker](/developers/issue-tracker.html)

[How To Become A Committer](/developers/how-to-become-a-committer.html)
[How To Become A Committer](/developers/how-to-become-a-committer.html)
Loading

0 comments on commit 6ddca38

Please sign in to comment.