semvec/pypi-packages huggingface dataset:
blqs-cirq 0.1.0
A library for writing imperative quantum computing programs in Cirq.
License: Apache 2
Requires Python: >=3.7.0

# blqs_cirq: Taking the pain out of writing Cirq programs

Blqs_cirq is a library that uses blqs to make it easier to write Cirq programs.

Here is the creation of a simple circuit in Cirq
```python
import cirq
circuit = cirq.Circuit()
q0, q1 = cirq.LineQubit.range(2)
circuit.append(cirq.H(q0))
circuit.append(cirq.CX(q0, q1))
circuit.append(measure(q0, key='a'))
```
Blqs_cirq makes it so that you can write this more like a normal imperative
program
```python
import blqs_cirq as bc
from blqs_cirq import CX, H, measure

# Write the function imperatively.
@bc.build
def my_circuit():
    H(0)
    CX(0, 1)
    measure(q0, key='a')

# To create the circuit we simply call the function.
circuit = my_circuit()
```

Blqs provides supports for all the gates in Cirq, along with all the various ways to use
these gates to create operations.

But wait, there is more.  Blqs_cirq supports

* Simplification of qubit specification.  Instead of creating `LineQubit` or `NamedQubit`, etc.,
one can simply use integers (converted to `LineQubit`s), 2-tuples or 2-lists (converted to
`GridQubit`s) or strings (converted to `NamedQubits`). Custom conversions are also possible.

* Simplification of control flow primitives. For example Cirq currently supports a subcircuit
which can be repeated. For example here we repeat a small circuit within our circuit:
```python
@bc.build
def my_circuit():
    H(1)
    with Repeat(repetitions=10):
        H(0)
        CX(0, 1)
```
As more control operations are added to Cirq these will be added to blqs_cirq.

* Simple building of Moments.  For example, the code below builds two moments:
```python
@bc.build
def my_circuit():
    with Moment():
        bc.H(0)
    with Moment():
        bc.H(1)
```

* Support for Cirq's insertion strategies:
```python
@bc.build
def my_circuit():
    with bc.InsertStrategy(cirq.InsertStrategy.NEW):
        H(0)
        H(1)
```

# Installation

To install blqs_cirq one can simply pip install the appropriate package
```
pip install blqs_cirq
```
Note that installing blqs_cirq will also install blqs and cirq.

# Documentation

A good place to start is with the [introduction](docs/intro.md), followed by a look
at the important [features](docs/features.md). For a quick intro via a jupyter notebook,
see [hello blqs_cirq](hello_blqs_cirq.ipynb).
blqs 0.1.0
Python building blocks for internal domain specific languages.
License: Apache 2
Requires Python: >=3.7.0

# blqs: Building Blocks for Domain Specific Languages

Blqs is a framework for building (internal) domain specific language that can be written
in Python. It was inspired by TensorFlow's autograph library, and motivated by the state of
the art (circa 2021) in quantum programming frameworks like Cirq and Qiskit.

In short blqs let you define domain specific languages and gives you access to use native
Python features like `if`, `while`, or `for` in these languages. This fills in a missing
feature for Python, which while they do have operator overloading, does not allow for
overloading these built in constructions.

Example:
```python
import blqs
H, M, CX = blqs.Op('H'), blqs.Op('M'), blqs.Op('CX')

@blqs.build
def hello_blqs():
    a = blqs.Register('a')
    H(0)
    M(0, 'a')
    if a:
        CX(0, 1)
    else:
        CX(1, 0)
```
Then, if we call this method, we will produce a `blqs.Program` that includes both statements,
like `H(0)` but also the `if` and `else` statements.
```python
program = hello_blqs()
for s in program:
    print(type(s))
> prints
> <class 'blqs.instruction.Instruction'>
> <class 'blqs.instruction.Instruction'>
> <class 'blqs.conditional.If'>
```
Where the last statement contains blocks that hold the `CX` statements.

# Installation

To install blqs one can simply pip install the appropriate package
```
pip install blqs
```
See [requirements.txt](requirements.txt) for the dependencies that blqs will
pull in.

# Documentation

A good place to get started is to read the [introduction to blqs](docs/intro.md).
After that, the ideas and abstractions in blqs are described in the
[concepts guide](docs/concepts.md). To learn about support for capturing native
python code, see refer to the [protocols section](docs/protocols.md) of the docs.
For a quick intro via a jupyter notebook, see [hello blqs](hello_blqs.ipynb).