# UCQ_tools
## Resources
- PyPi: See the project on pypi for the download at: https://pypi.org/project/UC-Quantum-tools/
- GitHub: See the project repo at: https://github.com/UC-Advanced-Research-Computing/UC-Quantum-tools
## Bugs
If you encounter a bug please make an issue in the "issues" tab above. This is a maintained repo and we will respond.
## Contributing
Anyone who wants to contribute to the code, please do. Download the code, modify it, and create a pull request.
## Available Functions
- **NOTE:** This package detects if you are using the vscode extension by checking if the ".UCQ_config" directory is in the directory that you are currently running the python file.
- `state`
- **Description**: Displays a vector in vscode if using the UC_Quantum_Lab vscode extension. And no matter where you are using this function it will return the state vector as a list.
- **inputs**:
- `circuit:QuantumCircuit`: a qiskit quantum circuit **with no measurements in it**.
- `show:boolean` (optional): a boolean indicating if you want to display the statevector in the UC_Quantum_Lab vscode extension (default is yes if using the extension).
- **returns**:
- `statevector:list[complex]`: the statevector of the circuit in little endian format (this is how qiskit orders bits) in list form. You do not have to use this return (just do not assign it to a variable).
- **NOTE**: this function can be multiple times (whenever you can this function the statevector of the circuit up to the call will be created).
- **Example Useage** (some ways to use it, not all)
```python
from UC_Quantum_Lab import state
import qiskit
quantumcircuit = qiskit.QuantumCircuit(2, 2)
statevector = state(quantumciruit, show=True)
# or
statevector = state(quantumciruit)
# or
state(quantumciruit)
```
- `display`
- **Description**: Displays a circuit diagram (if a circuit is passed to this function) or a matplotlib figure (if a matplotlib figure is passed to this fucntion) in vscode if using the UC_Quantum_Lab vscode extension. If you are not using the vscode extension, then:
- if you provide input *path* then the circuit diagram will be saved to that path.
- if you do *not* input *path* then a matplotlib figure will pop up.
- **inputs**:
- `obj:QuantumCircuit|matplotlib.figure.Figure|None`: a qiskit quantum circuit or matplotlib figure. If you do not provide this argument (i.e. it is None), then the latest matplotlib figure created will be displayed.
- `path:string` (optional): a string path that you want to save the figure to.
- `delete:bool` (optional): Default is `True`. Whether or not to delete the figure given to or created by this function after it is displayed. If the function is going to display a pop up figure then this will be set to false automatically.
- `dpi:int` (optional): The resolution in dots per inch (int, default is none which uses the dpi provided by matplotlib.
- **NOTE**: if you are not using this function with the UC_Quantum_Lab vscode extension and you do not provide the path then a matplotlib figure will pop up.
- **returns**: (nothing)
- **NOTE**: this function can be multiple times and it will just generate more images (whenever you can this function a diagram of the circuit up to the call will be created).
- **Example Useage** (some ways to use it, not all)
```python
from UC_Quantum_Lab import display
import matplotlib.pyplot as plt
import qiskit
quantumcircuit = qiskit.QuantumCircuit(2, 2)
display(quantumciruit, path="local.png")
# or
display(quantumciruit)
# or
fig = plt.figure()
# add stuff to figure
display(fig)
# or
plt.plot(x, y)
# add stuff to plot
display()
```
- `counts`
- **Description**: Displays a histogram in vscode if using the UC_Quantum_Lab vscode extension. If you are not using the vscode extension, then:
- if you provide input *path* then the histogram will be saved to that path.
- if you do *not* input *path* then a matplotlib figure will pop up.
- **inputs**:
- `circuit:QuantumCircuit`: a qiskit quantum circuit **that must have measurements in it**.
- `backend:simulator` (optional): the simulator to execute the circuit on, default is IBM's qasm simulator.
- `path:string` (optional): a string path that you want to save the figure to.
- `show:boolean` (optional): whether or not display the circuit, default is true. If false, then only the dictionary will be returned and nothing else will happen.
- `dpi:int` (optional): The resolution in dots per inch, default is none which uses the dpi provided by matplotlib.
- `shots:int` (optional): The number of times to execute the circuit.
- **NOTE**: if you are not using this function with the UC_Quantum_Lab vscode extension and you do not provide the path then a matplotlib figure will pop up.
- **returns**:
- `counts:dictionary[string, int]`: the results of the simulation of the circuit as a dictionay where the keys are the binary strings and the values of the keys are the number of the times the binary string is the output of the circuit out of 1024. You do not have to use this return (just do not assign it to a variable).
- **NOTE**: this function can be multiple times and it will just generate more images (and simulate the circuit at every call).
- **Example Useage** (some ways to use it, not all)
```python
from UC_Quantum_Lab import counts
import qiskit
quantumcircuit = qiskit.QuantumCircuit(2, 2)
result = counts(
quantumciruit,
backend=Aer.get_backend("statevector_simulator"),
path="local.png"
)
# or
counts(quantumciruit, path="local.png")
# or
result = counts(quantumcircuit)
# or
counts(quantumcircuit)
```
- `invert`
- **Description**: This only works with the vscode extension UC_Quantum_Lab. Inverts the tiling of the extension's UI vertically and horizontally from default.
- **inputs** (nothing)
- **returns** (nothing)
- **Example Useage**
```python
from UC_Quantum_Lab import invert
invert()
```
- `horizontal_invert`
- **Description**: This only works with the vscode extension UC_Quantum_Lab. Inverts the tiling of the extension's UI horizontally from default.
- **inputs** (nothing)
- **returns** (nothing)
- **Example Useage**
```python
from UC_Quantum_Lab import horizontal_invert
horizontal_invert()
```
- `vertical_invert`
- **Description**: This only works with the vscode extension UC_Quantum_Lab. Inverts the tiling of the extension's UI vertically from default.
- **inputs** (nothing)
- **returns** (nothing)
- **Example Useage**
```python
from UC_Quantum_Lab import vertical_invert
vertical_invert()
```
- `custom`
- **Description**: This only works with the vscode extension UC_Quantum_Lab. Creates a custom webview from the inputted json using the format specified in https://github.com/brodkemd/UC_Quantum_Lab in the "*About json to html converter*" section.
- **inputs**:
- `layout_json:JSON`: json style object to set to the webviewer html.
- **returns** (nothing)
- **Example Useage**
```python
from UC_Quantum_Lab import custom
custom({"left": "<h1>hello</h1>", "right" : "<h1>hello</h1>"})
```
- **NOTE**: if you call this function before you call the inverts above the inverts will apply.
- `get_binary_strings`
- **Description**: Generates all possible binary strings using the number of qubits that is inputted.
- **inputs**
- `num_qubits:int`: number of qubits (or normal bits) to generate all possible binary strings for.
- **returns**
- `binary_strings:list[str]`: List of all possible binary strings, this scales exponentially so things can quickly get out of hand.
- **Example Useage**
```python
from UC_Quantum_Lab import get_binary_string
num_bits = 3
strings = get_binary_string(num_bits)
```
- `Image`
- **Description**: Converts the inputted image path to an html element able to be rendered by the UC_Quantum_Lab extension for vscode.
- **inputs**
- `path:string`: path to an image to be displayed.
- **returns**
- `html:str`: the html required to load the image.
- **Example Useage**
```python
from UC_Quantum_Lab import Image
image_path = "hello.png"
img_element = Image(image_path)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/UC-Advanced-Research-Computing/UC-Quantum-tools",
"name": "UC-Quantum-tools",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "development",
"author": "Marek Brodke, with support from the University of Cincinnati",
"author_email": "brodkemd@mail.uc.edu",
"download_url": "https://files.pythonhosted.org/packages/82/d8/d99513f5214b0246fb10cd69e15bd08f8c80c694a033aa219264b12c41e3/UC-Quantum-tools-0.1.15.tar.gz",
"platform": null,
"description": "# UCQ_tools\n## Resources\n- PyPi: See the project on pypi for the download at: https://pypi.org/project/UC-Quantum-tools/\n- GitHub: See the project repo at: https://github.com/UC-Advanced-Research-Computing/UC-Quantum-tools\n\n## Bugs\nIf you encounter a bug please make an issue in the \"issues\" tab above. This is a maintained repo and we will respond.\n\n## Contributing\nAnyone who wants to contribute to the code, please do. Download the code, modify it, and create a pull request.\n\n## Available Functions\n- **NOTE:** This package detects if you are using the vscode extension by checking if the \".UCQ_config\" directory is in the directory that you are currently running the python file.\n- `state`\n - **Description**: Displays a vector in vscode if using the UC_Quantum_Lab vscode extension. And no matter where you are using this function it will return the state vector as a list.\n - **inputs**:\n - `circuit:QuantumCircuit`: a qiskit quantum circuit **with no measurements in it**.\n - `show:boolean` (optional): a boolean indicating if you want to display the statevector in the UC_Quantum_Lab vscode extension (default is yes if using the extension).\n - **returns**:\n - `statevector:list[complex]`: the statevector of the circuit in little endian format (this is how qiskit orders bits) in list form. You do not have to use this return (just do not assign it to a variable).\n - **NOTE**: this function can be multiple times (whenever you can this function the statevector of the circuit up to the call will be created).\n - **Example Useage** (some ways to use it, not all)\n ```python\n from UC_Quantum_Lab import state\n import qiskit\n quantumcircuit = qiskit.QuantumCircuit(2, 2)\n\n statevector = state(quantumciruit, show=True)\n # or \n statevector = state(quantumciruit)\n # or \n state(quantumciruit)\n ```\n- `display`\n - **Description**: Displays a circuit diagram (if a circuit is passed to this function) or a matplotlib figure (if a matplotlib figure is passed to this fucntion) in vscode if using the UC_Quantum_Lab vscode extension. If you are not using the vscode extension, then:\n - if you provide input *path* then the circuit diagram will be saved to that path.\n - if you do *not* input *path* then a matplotlib figure will pop up.\n - **inputs**:\n - `obj:QuantumCircuit|matplotlib.figure.Figure|None`: a qiskit quantum circuit or matplotlib figure. If you do not provide this argument (i.e. it is None), then the latest matplotlib figure created will be displayed.\n - `path:string` (optional): a string path that you want to save the figure to.\n - `delete:bool` (optional): Default is `True`. Whether or not to delete the figure given to or created by this function after it is displayed. If the function is going to display a pop up figure then this will be set to false automatically.\n - `dpi:int` (optional): The resolution in dots per inch (int, default is none which uses the dpi provided by matplotlib.\n - **NOTE**: if you are not using this function with the UC_Quantum_Lab vscode extension and you do not provide the path then a matplotlib figure will pop up.\n - **returns**: (nothing)\n - **NOTE**: this function can be multiple times and it will just generate more images (whenever you can this function a diagram of the circuit up to the call will be created).\n - **Example Useage** (some ways to use it, not all)\n ```python\n from UC_Quantum_Lab import display\n import matplotlib.pyplot as plt\n import qiskit\n quantumcircuit = qiskit.QuantumCircuit(2, 2)\n\n display(quantumciruit, path=\"local.png\")\n # or \n display(quantumciruit)\n # or\n fig = plt.figure()\n # add stuff to figure\n display(fig)\n # or\n plt.plot(x, y)\n # add stuff to plot\n display()\n ```\n- `counts`\n - **Description**: Displays a histogram in vscode if using the UC_Quantum_Lab vscode extension. If you are not using the vscode extension, then:\n - if you provide input *path* then the histogram will be saved to that path.\n - if you do *not* input *path* then a matplotlib figure will pop up.\n - **inputs**:\n - `circuit:QuantumCircuit`: a qiskit quantum circuit **that must have measurements in it**.\n - `backend:simulator` (optional): the simulator to execute the circuit on, default is IBM's qasm simulator. \n - `path:string` (optional): a string path that you want to save the figure to. \n - `show:boolean` (optional): whether or not display the circuit, default is true. If false, then only the dictionary will be returned and nothing else will happen.\n - `dpi:int` (optional): The resolution in dots per inch, default is none which uses the dpi provided by matplotlib.\n - `shots:int` (optional): The number of times to execute the circuit.\n - **NOTE**: if you are not using this function with the UC_Quantum_Lab vscode extension and you do not provide the path then a matplotlib figure will pop up.\n - **returns**:\n - `counts:dictionary[string, int]`: the results of the simulation of the circuit as a dictionay where the keys are the binary strings and the values of the keys are the number of the times the binary string is the output of the circuit out of 1024. You do not have to use this return (just do not assign it to a variable).\n - **NOTE**: this function can be multiple times and it will just generate more images (and simulate the circuit at every call).\n - **Example Useage** (some ways to use it, not all)\n ```python\n from UC_Quantum_Lab import counts\n import qiskit\n quantumcircuit = qiskit.QuantumCircuit(2, 2)\n\n result = counts(\n quantumciruit, \n backend=Aer.get_backend(\"statevector_simulator\"),\n path=\"local.png\"\n )\n # or \n counts(quantumciruit, path=\"local.png\")\n # or\n result = counts(quantumcircuit)\n # or\n counts(quantumcircuit)\n ```\n- `invert`\n - **Description**: This only works with the vscode extension UC_Quantum_Lab. Inverts the tiling of the extension's UI vertically and horizontally from default.\n - **inputs** (nothing)\n - **returns** (nothing)\n - **Example Useage**\n ```python\n from UC_Quantum_Lab import invert\n invert()\n ```\n- `horizontal_invert`\n - **Description**: This only works with the vscode extension UC_Quantum_Lab. Inverts the tiling of the extension's UI horizontally from default.\n - **inputs** (nothing)\n - **returns** (nothing)\n - **Example Useage**\n ```python\n from UC_Quantum_Lab import horizontal_invert\n horizontal_invert()\n ```\n- `vertical_invert`\n - **Description**: This only works with the vscode extension UC_Quantum_Lab. Inverts the tiling of the extension's UI vertically from default.\n - **inputs** (nothing)\n - **returns** (nothing)\n - **Example Useage**\n ```python\n from UC_Quantum_Lab import vertical_invert\n vertical_invert()\n ```\n- `custom`\n - **Description**: This only works with the vscode extension UC_Quantum_Lab. Creates a custom webview from the inputted json using the format specified in https://github.com/brodkemd/UC_Quantum_Lab in the \"*About json to html converter*\" section.\n - **inputs**:\n - `layout_json:JSON`: json style object to set to the webviewer html.\n - **returns** (nothing)\n - **Example Useage**\n ```python\n from UC_Quantum_Lab import custom\n custom({\"left\": \"<h1>hello</h1>\", \"right\" : \"<h1>hello</h1>\"})\n ```\n - **NOTE**: if you call this function before you call the inverts above the inverts will apply.\n\n- `get_binary_strings`\n - **Description**: Generates all possible binary strings using the number of qubits that is inputted.\n - **inputs**\n - `num_qubits:int`: number of qubits (or normal bits) to generate all possible binary strings for. \n - **returns**\n - `binary_strings:list[str]`: List of all possible binary strings, this scales exponentially so things can quickly get out of hand.\n - **Example Useage**\n ```python\n from UC_Quantum_Lab import get_binary_string\n num_bits = 3\n strings = get_binary_string(num_bits)\n ```\n- `Image`\n - **Description**: Converts the inputted image path to an html element able to be rendered by the UC_Quantum_Lab extension for vscode.\n - **inputs**\n - `path:string`: path to an image to be displayed. \n - **returns**\n - `html:str`: the html required to load the image.\n - **Example Useage**\n ```python\n from UC_Quantum_Lab import Image\n image_path = \"hello.png\"\n img_element = Image(image_path)\n ```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Provides functionaliy for UC-Quantum-Lab development tools",
"version": "0.1.15",
"split_keywords": [
"development"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "82d8d99513f5214b0246fb10cd69e15bd08f8c80c694a033aa219264b12c41e3",
"md5": "b8e6b06eef426c0ba39783b44b41c2df",
"sha256": "9cbbac0402765ab355fbe6e2462191acdcda82de1ccc769d126ece1cf3f32f82"
},
"downloads": -1,
"filename": "UC-Quantum-tools-0.1.15.tar.gz",
"has_sig": false,
"md5_digest": "b8e6b06eef426c0ba39783b44b41c2df",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 9964,
"upload_time": "2023-01-18T02:05:04",
"upload_time_iso_8601": "2023-01-18T02:05:04.776572Z",
"url": "https://files.pythonhosted.org/packages/82/d8/d99513f5214b0246fb10cd69e15bd08f8c80c694a033aa219264b12c41e3/UC-Quantum-tools-0.1.15.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-18 02:05:04",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "UC-Advanced-Research-Computing",
"github_project": "UC-Quantum-tools",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "uc-quantum-tools"
}