Commit db9ceb3f authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

Merge branch 'master' into mccaskey/qcs_2021_work

parents cfb7b740 cb3db9b8
......@@ -22,17 +22,17 @@ docker build_master:
- git config remote.aideqc.url >&- || git remote add -t master aideqc https://amccaskey:$AIDEQC_ACCESS_TOKEN@github.com/aide-qc/xacc
- git push -f aideqc HEAD:master
- git remote remove aideqc
- git clone https://github.com/aide-qc/homebrew-deploy && cd homebrew-deploy
- git clone --depth=1 --recursive https://github.com/eclipse/xacc
- tar -czvf xacc-1.0.0.tar.gz xacc
- jfrog bt u --override --publish xacc-1.0.0.tar.gz amccaskey/qci-homebrew-bintray/xacc-source/xacc-1.0.0
- export src_sha=$(sha256sum xacc-1.0.0.tar.gz | cut -d " " -f 1)
- sed -i "0,/sha256 \".*\"/s//sha256 \"$src_sha\" /" Formula/xacc.rb
- git add Formula/xacc.rb
- git commit -m "updating sha256 for xacc homebrew formula"
- git config remote.aideqchbdeploy.url >&- || git remote add -t master aideqchbdeploy https://amccaskey:$AIDEQC_ACCESS_TOKEN@github.com/aide-qc/homebrew-deploy
- git push -f aideqchbdeploy HEAD:master
- git remote remove aideqchbdeploy
# - git clone https://github.com/aide-qc/homebrew-deploy && cd homebrew-deploy
# - git clone --depth=1 --recursive https://github.com/eclipse/xacc
# - tar -czvf xacc-1.0.0.tar.gz xacc
# - jfrog bt u --override --publish xacc-1.0.0.tar.gz amccaskey/qci-homebrew-bintray/xacc-source/xacc-1.0.0
# - export src_sha=$(sha256sum xacc-1.0.0.tar.gz | cut -d " " -f 1)
# - sed -i "0,/sha256 \".*\"/s//sha256 \"$src_sha\" /" Formula/xacc.rb
# - git add Formula/xacc.rb
# - git commit -m "updating sha256 for xacc homebrew formula"
# - git config remote.aideqchbdeploy.url >&- || git remote add -t master aideqchbdeploy https://amccaskey:$AIDEQC_ACCESS_TOKEN@github.com/aide-qc/homebrew-deploy
# - git push -f aideqchbdeploy HEAD:master
# - git remote remove aideqchbdeploy
docker run_docker_deploy:
stage: deploy
......
......@@ -123,6 +123,9 @@ IF(CMAKE_BUILD_TYPE MATCHES "Debug" OR CMAKE_BUILD_TYPE MATCHES "DEBUG")
add_compile_definitions(_XACC_DEBUG)
ENDIF()
# Find LAPACK (optional)
find_package(LAPACK)
add_subdirectory(xacc)
add_subdirectory(quantum)
......
%% Cell type:markdown id: tags:
## Utility Classes to support JSON generation
%% Cell type:code id: tags:
``` python
import json
class XaccJSONEncoder(json.JSONEncoder):
"""
JSON encoder for NumPy arrays and complex numbers.
This functions as the standard JSON Encoder but adds support
for encoding:
complex numbers z as lists [z.real, z.imag]
numpy.ndarrays as nested lists.
"""
def default(self, obj):
if isinstance(obj, np.ndarray):
return obj.tolist()
if isinstance(obj, complex):
return [obj.real, obj.imag]
if hasattr(obj, "to_dict"):
return obj.to_dict()
return super().default(obj)
def clean_nones(value):
"""
Recursively remove all None values from dictionaries and lists, and returns
the result as a new dictionary or list.
"""
if isinstance(value, list):
return [clean_nones(x) for x in value if x is not None]
elif isinstance(value, dict):
return {
key: clean_nones(val)
for key, val in value.items()
if val is not None
}
else:
return value
def json_serialize(obj):
return json.loads(json.dumps(clean_nones(obj), cls=XaccJSONEncoder))
```
%% Cell type:code id: tags:
``` python
class ChannelKrausOp:
'''
Represents a noise channel in terms of Kraus operators:
Args:
noise_qubits (List[String]): qubits that this operator acts on (If none, applying on gate qubits)
matrix: the list of Kraus ops (as square matrices) representing a noise channel.
Note: must satisfy the CPTP condition
'''
def __init__(self, matrix, noise_qubits = None):
self.matrix = matrix
self.noise_qubits = noise_qubits
"""
Returns:
dict: a (JSON) dictionary for a KrausOp
"""
def to_dict(self):
kraus = {
"matrix": list(self.matrix),
"noise_qubits": self.noise_qubits
}
return json_serialize(kraus)
```
%% Cell type:code id: tags:
``` python
class GateNoise:
'''
Represents noise ops (as a list of Kraus operators) associated with a quantum gate
Args:
name (string): gate name
register_location (List[String]): gate qubits (as a list of register labels)
noise_channels (List[KrausOp]): list of noise channels
'''
def __init__(self, name, register_location, noise_kraus_ops):
self.name = name
self.register_location = register_location
self.noise_kraus_ops = noise_kraus_ops
def to_dict(self):
gate_noise = {
"gate_name": self.name,
"register_location": self.register_location,
"noise_channels": self.noise_kraus_ops
}
return json_serialize(gate_noise)
```
%% Cell type:code id: tags:
``` python
class ReadoutError: