Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/export_a_dds_to_qiskit.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"from matplotlib.gridspec import GridSpec\n",
"\n",
"#Q-CTRL Open Controls\n",
"from qctrlopencontrols import new_predefined_dds, convert_dds_to_quantum_circuit\n",
"from qctrlopencontrols import new_predefined_dds, convert_dds_to_qiskit_quantum_circuit\n",
"\n",
"#Qiskit\n",
"##To define a backend (simulated or real)\n",
Expand Down Expand Up @@ -166,7 +166,7 @@
"\n",
"## convert the quadratic sequence to QuantumCircuit\n",
"\n",
"quadratic_quantum_circuit = convert_dds_to_quantum_circuit(\n",
"quadratic_quantum_circuit = convert_dds_to_qiskit_quantum_circuit(\n",
" dynamic_decoupling_sequence=quadratic_sequence,\n",
" target_qubits=target_qubits,\n",
" gate_time=gate_time,\n",
Expand All @@ -176,7 +176,7 @@
"\n",
"## convert the ramsey sequence to QuantumCircuit\n",
"circuit_name = 'ramsey-sequence-circuit'\n",
"ramsey_quantum_circuit = convert_dds_to_quantum_circuit(\n",
"ramsey_quantum_circuit = convert_dds_to_qiskit_quantum_circuit(\n",
" dynamic_decoupling_sequence=ramsey_sequence,\n",
" target_qubits=target_qubits,\n",
" gate_time=gate_time,\n",
Expand Down
29 changes: 21 additions & 8 deletions qctrlopencontrols/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,27 @@

"""
=================
qcrtlopencontrols
qctrlopencontrols
=================
"""

from .dynamic_decoupling_sequences import (DynamicDecouplingSequence,
new_predefined_dds,
convert_dds_to_driven_control)
from .driven_controls import DrivenControl, new_predefined_driven_control
from .qiskit import convert_dds_to_quantum_circuit
from .cirq import (convert_dds_to_cirq_circuit,
convert_dds_to_cirq_schedule)
from .cirq.circuit import convert_dds_to_cirq_circuit
from .cirq.schedule import convert_dds_to_cirq_schedule

from .driven_controls.driven_control import DrivenControl
from .driven_controls.predefined import new_predefined_driven_control

from .dynamic_decoupling_sequences.dynamic_decoupling_sequence import DynamicDecouplingSequence
from .dynamic_decoupling_sequences.predefined import new_predefined_dds
from .dynamic_decoupling_sequences.driven_controls import convert_dds_to_driven_control

from .qiskit.quantum_circuit import convert_dds_to_qiskit_quantum_circuit

__all__ = ['convert_dds_to_cirq_circuit',
'convert_dds_to_cirq_schedule',
'convert_dds_to_driven_control',
'convert_dds_to_qiskit_quantum_circuit',
'new_predefined_dds',
'new_predefined_driven_control',
'DrivenControl',
'DynamicDecouplingSequence']
8 changes: 0 additions & 8 deletions qctrlopencontrols/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,3 @@
# 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.

"""
===========
Base module
===========
"""

from .qctrl_object import QctrlObject
107 changes: 0 additions & 107 deletions qctrlopencontrols/base/qctrl_object.py

This file was deleted.

77 changes: 77 additions & 0 deletions qctrlopencontrols/base/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Copyright 2019 Q-CTRL Pty Ltd & Q-CTRL Inc
#
# 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.

"""
==========
base.utils
==========
"""

from ..exceptions.exceptions import ArgumentsValueError


def create_repr_from_attributes(class_instance=None, attributes=None):

"""Returns a string representation of an object

Parameters
----------
class_instance : object, optional
The instance of a class (object)l defaults to None
attributes : list, optional
A list of string where each entry is the name of the attribute to collect
from the class instance.

Returns
-------
str
A string representing the attributes; If no attribute is provided
a constant string is returned
'No attributes provided for object of class {0.__class__.__name__}".
format(class_instance)'

Raises
------
ArgumentsValueError
If class name is not a string or any of the attribute name is not string type
"""

if class_instance is None:
raise ArgumentsValueError('Class instance must be a valid object.',
{'class_instance': class_instance})

class_name = '{0.__class__.__name__}'.format(class_instance)

if attributes is None:
raise ArgumentsValueError('Attributes must be a list of string',
{'attributes': attributes})

if not attributes:
return "No attributes provided for object of class {0}".format(class_name)

for attribute in attributes:
if not isinstance(attribute, str):
raise ArgumentsValueError('Each attribute name must be a string. Found '
'{0} type.'.format(type(attribute)),
{'attribute': attribute,
'type(attribute)': type(attribute)})

repr_string = '{0}('.format(class_name)
attributes_string = ','.join('{0}={1}'.format(attribute,
repr(getattr(class_instance, attribute)))
for attribute in attributes)
repr_string += attributes_string
repr_string += ')'

return repr_string
9 changes: 0 additions & 9 deletions qctrlopencontrols/cirq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,3 @@
# 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.

"""
=============
cirq module
=============
"""

from .circuit import convert_dds_to_cirq_circuit
from .schedule import convert_dds_to_cirq_schedule
6 changes: 3 additions & 3 deletions qctrlopencontrols/cirq/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

import cirq

from qctrlopencontrols.dynamic_decoupling_sequences import DynamicDecouplingSequence
from qctrlopencontrols.exceptions import ArgumentsValueError
from qctrlopencontrols.globals import (FIX_DURATION_UNITARY, INSTANT_UNITARY)
from ..dynamic_decoupling_sequences.dynamic_decoupling_sequence import DynamicDecouplingSequence
from ..exceptions.exceptions import ArgumentsValueError
from ..globals import (FIX_DURATION_UNITARY, INSTANT_UNITARY)


def convert_dds_to_cirq_circuit(
Expand Down
4 changes: 2 additions & 2 deletions qctrlopencontrols/cirq/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

import cirq

from qctrlopencontrols.dynamic_decoupling_sequences import DynamicDecouplingSequence
from qctrlopencontrols.exceptions import ArgumentsValueError
from ..dynamic_decoupling_sequences.dynamic_decoupling_sequence import DynamicDecouplingSequence
from ..exceptions.exceptions import ArgumentsValueError


def convert_dds_to_cirq_schedule(
Expand Down
92 changes: 65 additions & 27 deletions qctrlopencontrols/driven_controls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,68 @@
# limitations under the License.

"""
=============
driven_controls module
=============
"""

from .driven_control import DrivenControl

from .constants import (
UPPER_BOUND_RABI_RATE, UPPER_BOUND_DETUNING_RATE,
UPPER_BOUND_DURATION, LOWER_BOUND_DURATION, UPPER_BOUND_SEGMENTS,
PRIMITIVE, BB1, SK1,
WAMF1,
CORPSE,
CORPSE_IN_SK1,
CORPSE_IN_BB1,
SCROFULOUS,
CORPSE_IN_SCROFULOUS)

from .predefined import (
new_predefined_driven_control,
new_primitive_control, new_wimperis_1_control, new_solovay_kitaev_1_control,
new_compensating_for_off_resonance_with_a_pulse_sequence_control,
new_compensating_for_off_resonance_with_a_pulse_sequence_with_solovay_kitaev_control,
new_compensating_for_off_resonance_with_a_pulse_sequence_with_wimperis_control,
new_short_composite_rotation_for_undoing_length_over_and_under_shoot_control,
new_walsh_amplitude_modulated_filter_1_control,
new_corpse_in_scrofulous_control)
===============
driven_controls
===============
"""

##### Maximum and Minimum bounds ######

UPPER_BOUND_RABI_RATE = 1e10
"""Maximum allowed rabi rate
"""

UPPER_BOUND_DETUNING_RATE = UPPER_BOUND_RABI_RATE
"""Maximum allowed detuning rate
"""

UPPER_BOUND_DURATION = 1e6
"""Maximum allowed duration of a control
"""

LOWER_BOUND_DURATION = 1e-12
"""Minimum allowed duration of a control
"""

UPPER_BOUND_SEGMENTS = 10000
"""Maximum number of segments allowed in a control
"""

##### Types of driven controls ######

PRIMITIVE = 'primitive'
"""Primitive control
"""

BB1 = 'BB1'
"""First-order Wimperis control, also known as BB1
"""

SK1 = 'SK1'
"""First-order Solovay-Kitaev control
"""

WAMF1 = 'WAMF1'
"""First-order Walsh sequence control
"""

CORPSE = 'CORPSE'
"""Dynamically corrected control - Compensating for Off-Resonance with a Pulse Sequence (COPRSE)
"""

CORPSE_IN_BB1 = 'CORPSE in BB1'
"""Concatenated dynamically corrected control - BB1 inside COPRSE
"""

CORPSE_IN_SK1 = 'CORPSE in SK1'
"""Concatenated dynamically corrected control - First order Solovay-Kitaev inside COPRSE
"""

SCROFULOUS = 'SCROFULOUS'
"""Dynamically corrected control -
Short Composite Rotation For Undoing Length Over and Under Shoot (SCROFULOUS)
"""

CORPSE_IN_SCROFULOUS = 'CORPSE in SCROFULOUS'
"""Concatenated dynamically corrected control - CORPSE inside SCROFULOUS
"""
Loading