index
int64
0
50.7k
project_path
stringclasses
279 values
completion_path
stringlengths
57
199
signature_postion
stringlengths
3
11
class_position
stringlengths
3
11
function_name
stringlengths
1
62
class_name
stringlengths
0
55
body_position
stringlengths
3
11
body_position_with_comments
stringlengths
3
11
masked_class
stringlengths
14
8.32k
masked_class_with_comment
stringlengths
14
8.32k
func_body
stringlengths
9
6.72k
func_body_with_comment
stringlengths
9
6.72k
len_func_body
int64
1
643
len_input
int64
10
2.02k
len_output
int64
4
1.9k
total
int64
20
2.05k
file_code
stringlengths
14
442k
file_code_with_comment
stringlengths
14
442k
30,563
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/providers/models/pulsedefaults.py
35,36
22,58
to_dict
MeasurementKernel
41,43
36,43
class MeasurementKernel: """Class representing a Measurement Kernel.""" def __init__(self, name, params): """Initialize a MeasurementKernel object Args: name (str): The name of the measurement kernel params: The parameters of the measurement kernel """ s...
class MeasurementKernel: """Class representing a Measurement Kernel.""" def __init__(self, name, params): """Initialize a MeasurementKernel object Args: name (str): The name of the measurement kernel params: The parameters of the measurement kernel """ s...
return {"name": self.name, "params": self.params}
"""Return a dictionary format representation of the MeasurementKernel. Returns: dict: The dictionary form of the MeasurementKernel. """ return {"name": self.name, "params": self.params}
5
258
20
278
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,564
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/providers/models/pulsedefaults.py
227,228
163,305
to_dict
PulseDefaults
232,262
228,262
class PulseDefaults: """Description of default settings for Pulse systems. These are instructions or settings that may be good starting points for the Pulse user. The user may modify these defaults for custom scheduling. """ _data = {} def __init__( self, qubit_freq_est: List[f...
class PulseDefaults: """Description of default settings for Pulse systems. These are instructions or settings that may be good starting points for the Pulse user. The user may modify these defaults for custom scheduling. """ _data = {} def __init__( self, qubit_freq_est: List[f...
out_dict = { "qubit_freq_est": self.qubit_freq_est, "meas_freq_est": self.qubit_freq_est, "buffer": self.buffer, "pulse_library": [x.to_dict() for x in self.pulse_library], "cmd_def": [x.to_dict() for x in self.cmd_def], } if hasattr(se...
"""Return a dictionary format representation of the PulseDefaults. Returns: dict: The dictionary form of the PulseDefaults. """ out_dict = { "qubit_freq_est": self.qubit_freq_est, "meas_freq_est": self.qubit_freq_est, "buffer": self.buffer,...
78
1,220
421
1,641
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,566
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/providers/provider.py
47,54
42,96
get_backend
ProviderV1
67,75
54,75
class ProviderV1(Provider, ABC): """Base class for a Backend Provider.""" version = 1 @deprecate_func( since=1.1, additional_msg="The abstract Provider and ProviderV1 classes are deprecated and will be " "removed in 2.0. You can just remove it as the parent class and a `get_backen...
class ProviderV1(Provider, ABC): """Base class for a Backend Provider.""" version = 1 @deprecate_func( since=1.1, additional_msg="The abstract Provider and ProviderV1 classes are deprecated and will be " "removed in 2.0. You can just remove it as the parent class and a `get_backen...
backends = self.backends(name, **kwargs) if len(backends) > 1: raise QiskitBackendNotFoundError("More than one backend matches the criteria") if not backends: raise QiskitBackendNotFoundError("No backend matches the criteria") return backends[0]
"""Return a single backend matching the specified filtering. Args: name (str): name of the backend. **kwargs: dict used for filtering. Returns: Backend: a backend matching the filtering. Raises: QiskitBackendNotFoundError: if no backend ...
27
405
87
492
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,567
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/providers/providerutils.py
72,75
1,109
resolve_backend_name
93,109
75,109
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# account for BackendV2 available = [] for backend in backends: available.append(backend.name() if backend.version == 1 else backend.name) resolved_name = deprecated.get(name, aliased.get(name, name)) if isinstance(resolved_name, list): resolved_name = next((b for b in resolved_name...
"""Resolve backend name from a deprecated name or an alias. A group will be resolved in order of member priorities, depending on availability. Args: name (str): name of backend to resolve backends (list[Backend]): list of available backends. deprecated (dict[str: str]): dict of...
62
911
188
1,099
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,570
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/calibration_entries.py
263,264
228,290
get_schedule
CallableDef
264,278
264,278
class CallableDef(CalibrationEntry): """Python callback function that generates Qiskit Pulse program. A callable is inspected by the python built-in inspection module and provide the signature. This entry is parameterized by the function signature and .get_schedule method returns a non-parameterized pu...
class CallableDef(CalibrationEntry): """Python callback function that generates Qiskit Pulse program. A callable is inspected by the python built-in inspection module and provide the signature. This entry is parameterized by the function signature and .get_schedule method returns a non-parameterized pu...
try: # Python function doesn't allow partial bind, but default value can exist. to_bind = self._signature.bind(*args, **kwargs) to_bind.apply_defaults() except TypeError as ex: raise PulseError("Assigned parameter doesn't match with function signature.") f...
try: # Python function doesn't allow partial bind, but default value can exist. to_bind = self._signature.bind(*args, **kwargs) to_bind.apply_defaults() except TypeError as ex: raise PulseError("Assigned parameter doesn't match with function signature.") f...
51
427
180
607
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,571
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/calibration_entries.py
349,350
290,379
get_signature
PulseQobjDef
350,354
350,354
class PulseQobjDef(ScheduleDef): """Qobj JSON serialized format instruction sequence. A JSON serialized program can be converted into Qiskit Pulse program with the provided qobj converter. Because the Qobj JSON doesn't provide signature, conversion process occurs when the signature is requested for the...
class PulseQobjDef(ScheduleDef): """Qobj JSON serialized format instruction sequence. A JSON serialized program can be converted into Qiskit Pulse program with the provided qobj converter. Because the Qobj JSON doesn't provide signature, conversion process occurs when the signature is requested for the...
if self._definition is None: self._build_schedule() return super().get_signature()
if self._definition is None: self._build_schedule() return super().get_signature()
7
872
32
904
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,572
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/calibration_entries.py
148,149
113,228
_parse_argument
ScheduleDef
150,177
149,177
class ScheduleDef(CalibrationEntry): """In-memory Qiskit Pulse representation. A pulse schedule must provide signature with the .parameters attribute. This entry can be parameterized by a Qiskit Parameter object. The .get_schedule method returns a parameter-assigned pulse program. .. see_also:: ...
class ScheduleDef(CalibrationEntry): """In-memory Qiskit Pulse representation. A pulse schedule must provide signature with the .parameters attribute. This entry can be parameterized by a Qiskit Parameter object. The .get_schedule method returns a parameter-assigned pulse program. .. see_also:: ...
# This doesn't assume multiple parameters with the same name # Parameters with the same name are treated identically all_argnames = {x.name for x in self._definition.parameters} if self._user_arguments: if set(self._user_arguments) != all_argnames: raise Puls...
"""Generate signature from program and user provided argument names.""" # This doesn't assume multiple parameters with the same name # Parameters with the same name are treated identically all_argnames = {x.name for x in self._definition.parameters} if self._user_arguments: ...
76
827
271
1,098
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,573
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/channels.py
110,111
63,165
_validate_index
Channel
117,128
111,128
class Channel(metaclass=ABCMeta): """Base class of channels. Channels provide a Qiskit-side label for typical quantum control hardware signal channels. The final label -> physical channel mapping is the responsibility of the hardware backend. For instance, ``DriveChannel(0)`` holds instructions which the ba...
class Channel(metaclass=ABCMeta): """Base class of channels. Channels provide a Qiskit-side label for typical quantum control hardware signal channels. The final label -> physical channel mapping is the responsibility of the hardware backend. For instance, ``DriveChannel(0)`` holds instructions which the ba...
if isinstance(index, ParameterExpression) and index.parameters: # Parameters are unbound return elif isinstance(index, ParameterExpression): index = float(index) if index.is_integer(): index = int(index) if not isinstance(index, (i...
"""Raise a PulseError if the channel index is invalid, namely, if it's not a positive integer. Raises: PulseError: If ``index`` is not a nonnegative integer. """ if isinstance(index, ParameterExpression) and index.parameters: # Parameters are unbound ...
38
888
115
1,003
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,575
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/configuration.py
176,177
146,250
add_lo
LoConfig
178,189
177,189
class LoConfig: """Pulse channel LO frequency container.""" def __init__( self, channel_los: dict[DriveChannel | MeasureChannel, float] | None = None, lo_ranges: dict[DriveChannel | MeasureChannel, LoRange | tuple[int, int]] | None = None, ): """Lo channel configuration data...
class LoConfig: """Pulse channel LO frequency container.""" def __init__( self, channel_los: dict[DriveChannel | MeasureChannel, float] | None = None, lo_ranges: dict[DriveChannel | MeasureChannel, LoRange | tuple[int, int]] | None = None, ): """Lo channel configuration data...
if isinstance(channel, DriveChannel): # add qubit_lo_freq self.check_lo(channel, freq) self._q_lo_freq[channel] = freq elif isinstance(channel, MeasureChannel): # add meas_lo_freq self.check_lo(channel, freq) self._m_lo_freq[channel...
"""Add a lo mapping for a channel.""" if isinstance(channel, DriveChannel): # add qubit_lo_freq self.check_lo(channel, freq) self._q_lo_freq[channel] = freq elif isinstance(channel, MeasureChannel): # add meas_lo_freq self.check_lo(chan...
32
940
139
1,079
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,576
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/configuration.py
105,106
98,146
includes
LoRange
114,118
106,118
class LoRange: """Range of LO frequency.""" def __init__(self, lower_bound: float, upper_bound: float): self._lb = lower_bound self._ub = upper_bound def includes(self, lo_freq: complex) -> bool: FILL_FUNC_BODY @property def lower_bound(self) -> float: """Lower bound of the ...
class LoRange: """Range of LO frequency.""" def __init__(self, lower_bound: float, upper_bound: float): self._lb = lower_bound self._ub = upper_bound def includes(self, lo_freq: complex) -> bool: """Whether `lo_freq` is within the `LoRange`. Args: lo_freq: LO f...
if self._lb <= abs(lo_freq) <= self._ub: return True return False
"""Whether `lo_freq` is within the `LoRange`. Args: lo_freq: LO frequency to be validated Returns: bool: True if lo_freq is included in this range, otherwise False """ if self._lb <= abs(lo_freq) <= self._ub: return True return False ...
10
360
32
392
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,580
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/instructions/acquire.py
69,70
24,150
_validate
Acquire
78,90
70,90
class Acquire(Instruction): """The Acquire instruction is used to trigger the ADC associated with a particular qubit; e.g. instantiated with AcquireChannel(0), the Acquire command will trigger data collection for the channel associated with qubit 0 readout. This instruction also provides acquisition met...
class Acquire(Instruction): """The Acquire instruction is used to trigger the ADC associated with a particular qubit; e.g. instantiated with AcquireChannel(0), the Acquire command will trigger data collection for the channel associated with qubit 0 readout. This instruction also provides acquisition met...
if not isinstance(self.channel, AcquireChannel): raise PulseError(f"Expected an acquire channel, got {self.channel} instead.") if self.mem_slot and not isinstance(self.mem_slot, MemorySlot): raise PulseError(f"Expected a memory slot, got {self.mem_slot} instead.") if se...
"""Called after initialization to validate instruction data. Raises: PulseError: If the input ``channel`` is not type :class:`AcquireChannel`. PulseError: If the input ``mem_slot`` is not type :class:`MemorySlot`. PulseError: If the input ``reg_slot`` is not type :cl...
55
1,190
193
1,383
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,581
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/instructions/delay.py
54,56
21,70
channel
Delay
59,61
56,61
class Delay(Instruction): """A blocking instruction with no other effect. The delay is used for aligning and scheduling other instructions. Example: To schedule an instruction at time = 10, on a channel assigned to the variable ``channel``, the following could be used:: sched ...
class Delay(Instruction): """A blocking instruction with no other effect. The delay is used for aligning and scheduling other instructions. Example: To schedule an instruction at time = 10, on a channel assigned to the variable ``channel``, the following could be used:: sched ...
return self.operands[1]
"""Return the :py:class:`~qiskit.pulse.channels.Channel` that this instruction is scheduled on. """ return self.operands[1]
2
406
13
419
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,582
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/instructions/directives.py
29,31
23,35
duration
Directive
32,35
31,35
class Directive(instruction.Instruction, ABC): """A compiler directive. This is a hint to the pulse compiler and is not loaded into hardware. """ @property def duration(self) -> int: FILL_FUNC_BODY
class Directive(instruction.Instruction, ABC): """A compiler directive. This is a hint to the pulse compiler and is not loaded into hardware. """ @property def duration(self) -> int: """Duration of this instruction.""" FILL_FUNC_BODY
return 0
"""Duration of this instruction.""" return 0
2
76
10
86
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,583
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/instructions/directives.py
51,53
35,61
channels
RelativeBarrier
54,56
53,56
class RelativeBarrier(Directive): """Pulse ``RelativeBarrier`` directive.""" def __init__(self, *channels: chans.Channel, name: str | None = None): """Create a relative barrier directive. The barrier directive blocks instructions within the same schedule as the barrier on channels cont...
class RelativeBarrier(Directive): """Pulse ``RelativeBarrier`` directive.""" def __init__(self, *channels: chans.Channel, name: str | None = None): """Create a relative barrier directive. The barrier directive blocks instructions within the same schedule as the barrier on channels cont...
return self.operands
"""Returns the channels that this schedule uses.""" return self.operands
2
247
10
257
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,584
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/instructions/directives.py
120,121
61,147
_validate
TimeBlockade
126,131
121,131
class TimeBlockade(Directive): """Pulse ``TimeBlockade`` directive. This instruction is intended to be used internally within the pulse builder, to convert :class:`.Schedule` into :class:`.ScheduleBlock`. Because :class:`.ScheduleBlock` cannot take an absolute instruction time interval, this direct...
class TimeBlockade(Directive): """Pulse ``TimeBlockade`` directive. This instruction is intended to be used internally within the pulse builder, to convert :class:`.Schedule` into :class:`.ScheduleBlock`. Because :class:`.ScheduleBlock` cannot take an absolute instruction time interval, this direct...
if not isinstance(self.duration, int): raise PulseError( "TimeBlockade duration cannot be parameterized. Specify an integer duration value." )
"""Called after initialization to validate instruction data. Raises: PulseError: If the input ``duration`` is not integer value. """ if not isinstance(self.duration, int): raise PulseError( "TimeBlockade duration cannot be parameterized. Specify a...
17
744
48
792
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,585
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/instructions/frequency.py
62,64
24,85
frequency
SetFrequency
65,67
64,67
class SetFrequency(Instruction): r"""Set the channel frequency. This instruction operates on ``PulseChannel`` s. A ``PulseChannel`` creates pulses of the form .. math:: Re[\exp(i 2\pi f jdt + \phi) d_j]. Here, :math:`f` is the frequency of the channel. The instruction ``SetFrequency`` allows ...
class SetFrequency(Instruction): r"""Set the channel frequency. This instruction operates on ``PulseChannel`` s. A ``PulseChannel`` creates pulses of the form .. math:: Re[\exp(i 2\pi f jdt + \phi) d_j]. Here, :math:`f` is the frequency of the channel. The instruction ``SetFrequency`` allows ...
return self.operands[0]
"""New frequency.""" return self.operands[0]
2
535
13
548
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,586
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/instructions/frequency.py
124,126
85,133
channels
ShiftFrequency
127,129
126,129
class ShiftFrequency(Instruction): """Shift the channel frequency away from the current frequency.""" def __init__( self, frequency: Union[float, ParameterExpression], channel: PulseChannel, name: Optional[str] = None, ): """Creates a new shift frequency instruction....
class ShiftFrequency(Instruction): """Shift the channel frequency away from the current frequency.""" def __init__( self, frequency: Union[float, ParameterExpression], channel: PulseChannel, name: Optional[str] = None, ): """Creates a new shift frequency instruction....
return (self.channel,)
"""Returns the channels that this schedule uses.""" return (self.channel,)
2
412
11
423
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,588
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/instructions/phase.py
120,121
91,150
_validate
SetPhase
126,129
121,129
class SetPhase(Instruction): r"""The set phase instruction sets the phase of the proceeding pulses on that channel to ``phase`` radians. In particular, a PulseChannel creates pulses of the form .. math:: Re[\exp(i 2\pi f jdt + \phi) d_j] The ``SetPhase`` instruction sets :math:`\phi` to ...
class SetPhase(Instruction): r"""The set phase instruction sets the phase of the proceeding pulses on that channel to ``phase`` radians. In particular, a PulseChannel creates pulses of the form .. math:: Re[\exp(i 2\pi f jdt + \phi) d_j] The ``SetPhase`` instruction sets :math:`\phi` to ...
if not isinstance(self.channel, PulseChannel): raise PulseError(f"Expected a pulse channel, got {self.channel} instead.")
"""Called after initialization to validate instruction data. Raises: PulseError: If the input ``channel`` is not type :class:`PulseChannel`. """ if not isinstance(self.channel, PulseChannel): raise PulseError(f"Expected a pulse channel, got {self.channel} instead...
12
492
41
533
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,589
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/instructions/phase.py
59,60
26,91
_validate
ShiftPhase
65,68
60,68
class ShiftPhase(Instruction): r"""The shift phase instruction updates the modulation phase of proceeding pulses played on the same :py:class:`~qiskit.pulse.channels.Channel`. It is a relative increase in phase determined by the ``phase`` operand. In particular, a PulseChannel creates pulses of the for...
class ShiftPhase(Instruction): r"""The shift phase instruction updates the modulation phase of proceeding pulses played on the same :py:class:`~qiskit.pulse.channels.Channel`. It is a relative increase in phase determined by the ``phase`` operand. In particular, a PulseChannel creates pulses of the for...
if not isinstance(self.channel, PulseChannel): raise PulseError(f"Expected a pulse channel, got {self.channel} instead.")
"""Called after initialization to validate instruction data. Raises: PulseError: If the input ``channel`` is not type :class:`PulseChannel`. """ if not isinstance(self.channel, PulseChannel): raise PulseError(f"Expected a pulse channel, got {self.channel} instead...
12
587
41
628
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,590
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/instructions/play.py
83,85
26,98
parameters
Play
86,98
85,98
class Play(Instruction): """This instruction is responsible for applying a pulse on a channel. The pulse specifies the exact time dynamics of the output signal envelope for a limited time. The output is modulated by a phase and frequency which are controlled by separate instructions. The pulse duration...
class Play(Instruction): """This instruction is responsible for applying a pulse on a channel. The pulse specifies the exact time dynamics of the output signal envelope for a limited time. The output is modulated by a phase and frequency which are controlled by separate instructions. The pulse duration...
parameters: set[Parameter] = set() # Note that Pulse.parameters returns dict rather than set for convention. # We need special handling for Play instruction. for pulse_param_expr in self.pulse.parameters.values(): if isinstance(pulse_param_expr, ParameterExpression): ...
"""Parameters which determine the instruction behavior.""" parameters: set[Parameter] = set() # Note that Pulse.parameters returns dict rather than set for convention. # We need special handling for Play instruction. for pulse_param_expr in self.pulse.parameters.values(): ...
44
611
129
740
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,591
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/instructions/reference.py
61,62
22,99
_validate
Reference
68,77
62,77
class Reference(instruction.Instruction): """Pulse compiler directive that refers to a subroutine. If a pulse program uses the same subset of instructions multiple times, then using the :class:`~.Reference` class may significantly reduce the memory footprint of the program. This instruction only stores...
class Reference(instruction.Instruction): """Pulse compiler directive that refers to a subroutine. If a pulse program uses the same subset of instructions multiple times, then using the :class:`~.Reference` class may significantly reduce the memory footprint of the program. This instruction only stores...
for key in self.ref_keys: if not isinstance(key, str): raise PulseError(f"Keys must be strings. '{repr(key)}' is not a valid object.") if self.scope_delimiter in key or self.key_delimiter in key: raise PulseError( f"'{self.scope_delimit...
"""Called after initialization to validate instruction data. Raises: PulseError: When a key is not a string. PulseError: When a key in ``ref_keys`` contains the scope delimiter. """ for key in self.ref_keys: if not isinstance(key, str): ...
43
744
135
879
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,592
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/instructions/snapshot.py
42,43
23,81
_validate
Snapshot
48,51
43,51
class Snapshot(Instruction): """An instruction targeted for simulators, to capture a moment in the simulation.""" def __init__(self, label: str, snapshot_type: str = "statevector", name: Optional[str] = None): """Create new snapshot. Args: label: Snapshot label which is used to ide...
class Snapshot(Instruction): """An instruction targeted for simulators, to capture a moment in the simulation.""" def __init__(self, label: str, snapshot_type: str = "statevector", name: Optional[str] = None): """Create new snapshot. Args: label: Snapshot label which is used to ide...
if not isinstance(self.label, str): raise PulseError("Snapshot label must be a string.")
"""Called after initialization to validate instruction data. Raises: PulseError: If snapshot label is invalid. """ if not isinstance(self.label, str): raise PulseError("Snapshot label must be a string.")
11
499
31
530
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,594
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/library/pulse.py
77,87
29,147
draw
Pulse
120,134
87,134
class Pulse(ABC): """The abstract superclass for pulses. Pulses are complex-valued waveform envelopes. The modulation phase and frequency are specified separately from ``Pulse``s. """ __slots__ = ("duration", "name", "_limit_amplitude") limit_amplitude = True @abstractmethod def __init__(...
class Pulse(ABC): """The abstract superclass for pulses. Pulses are complex-valued waveform envelopes. The modulation phase and frequency are specified separately from ``Pulse``s. """ __slots__ = ("duration", "name", "_limit_amplitude") limit_amplitude = True @abstractmethod def __init__(...
# pylint: disable=cyclic-import from qiskit.visualization import pulse_drawer return pulse_drawer( program=self, style=style, backend=backend, time_range=time_range, time_unit=time_unit, show_waveform_info=show_waveform_inf...
"""Plot the interpolated envelope of pulse. Args: style: Stylesheet options. This can be dictionary or preset stylesheet classes. See :py:class:`~qiskit.visualization.pulse_v2.stylesheets.IQXStandard`, :py:class:`~qiskit.visualization.pulse_v2.stylesheets.IQX...
18
1,161
125
1,286
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,596
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/library/samplers/strategies.py
61,62
1,72
midpoint_sample
70,72
62,72
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
times = np.arange(1 / 2, duration + 1 / 2) return continuous_pulse(times, *args, **kwargs)
"""Sampling strategy for decorator. Args: continuous_pulse: Continuous pulse function to sample. duration: Duration to sample for. *args: Continuous pulse function args. **kwargs: Continuous pulse function kwargs. """ times = np.arange(1 / 2, duration + 1 / 2) return...
14
687
39
726
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,598
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/library/symbolic_pulses.py
187,188
138,213
_wrapped_lamb
LambdifiedExpression
188,200
188,200
class LambdifiedExpression: """Descriptor to lambdify symbolic expression with cache. When a new symbolic expression is assigned for the first time, :class:`.LambdifiedExpression` will internally lambdify the expressions and store the resulting callbacks in its cache. The next time it encounters the sa...
class LambdifiedExpression: """Descriptor to lambdify symbolic expression with cache. When a new symbolic expression is assigned for the first time, :class:`.LambdifiedExpression` will internally lambdify the expressions and store the resulting callbacks in its cache. The next time it encounters the sa...
if isinstance(args[0], np.ndarray): # When the args[0] is a vector ("t"), tile other arguments args[1:] # to prevent evaluation from looping over each element in t. t = args[0] args = np.hstack( ...
if isinstance(args[0], np.ndarray): # When the args[0] is a vector ("t"), tile other arguments args[1:] # to prevent evaluation from looping over each element in t. t = args[0] args = np.hstack( ...
44
671
143
814
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,600
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/library/waveform.py
57,58
23,138
_clip
Waveform
75,108
58,108
class Waveform(Pulse): """A pulse specified completely by complex-valued samples; each sample is played for the duration of the backend cycle-time, dt. """ def __init__( self, samples: np.ndarray | list[complex], name: str | None = None, epsilon: float = 1e-7, li...
class Waveform(Pulse): """A pulse specified completely by complex-valued samples; each sample is played for the duration of the backend cycle-time, dt. """ def __init__( self, samples: np.ndarray | list[complex], name: str | None = None, epsilon: float = 1e-7, li...
samples_norm = np.abs(samples) to_clip = (samples_norm > 1.0) & (samples_norm <= 1.0 + epsilon) if np.any(to_clip): # first try normalizing by the abs value clip_where = np.argwhere(to_clip) clip_angle = np.angle(samples[clip_where]) clipped_sampl...
"""If samples are within epsilon of unit norm, clip sample by reducing norm by (1-epsilon). If difference is greater than epsilon error is raised. Args: samples: Complex array of the samples in the pulse envelope. epsilon: Pulse sample norm tolerance for clipping. ...
120
847
458
1,305
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,601
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/parameter_manager.py
100,101
72,127
_get_visitor
NodeVisitor
102,111
101,111
class NodeVisitor: """A node visitor base class that walks instruction data in a pulse program and calls visitor functions for every node. Though this class implementation is based on Python AST, each node doesn't have a dedicated node class due to the lack of an abstract syntax tree for pulse programs...
class NodeVisitor: """A node visitor base class that walks instruction data in a pulse program and calls visitor functions for every node. Though this class implementation is based on Python AST, each node doesn't have a dedicated node class due to the lack of an abstract syntax tree for pulse programs...
if node_class == object: return self.generic_visit try: return getattr(self, f"visit_{node_class.__name__}") except AttributeError: # check super class return self._get_visitor(node_class.__base__)
"""A helper function to recursively investigate superclass visitor method.""" if node_class == object: return self.generic_visit try: return getattr(self, f"visit_{node_class.__name__}") except AttributeError: # check super class return se...
18
535
83
618
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,602
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/parameter_manager.py
282,283
257,324
visit_AlignmentKind
ParameterGetter
284,290
283,290
class ParameterGetter(NodeVisitor): """Node visitor for parameter finding. This visitor initializes empty parameter array, and recursively visits nodes and add parameters found to the array. """ def __init__(self): self.parameters = set() # Top layer: Get parameters from programs ...
class ParameterGetter(NodeVisitor): """Node visitor for parameter finding. This visitor initializes empty parameter array, and recursively visits nodes and add parameters found to the array. """ def __init__(self): self.parameters = set() # Top layer: Get parameters from programs ...
for param in node._context_params: if isinstance(param, ParameterExpression): self.parameters |= param.parameters # Mid layer: Get parameters from instructions
"""Get parameters from block's ``AlignmentKind`` specification.""" for param in node._context_params: if isinstance(param, ParameterExpression): self.parameters |= param.parameters # Mid layer: Get parameters from instructions
17
586
50
636
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,603
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/parameter_manager.py
365,373
324,446
assign_parameters
ParameterManager
383,392
373,392
class ParameterManager: """Helper class to manage parameter objects associated with arbitrary pulse programs. This object is implicitly initialized with the parameter object storage that stores parameter objects added to the parent pulse program. Parameter assignment logic is implemented based on the ...
class ParameterManager: """Helper class to manage parameter objects associated with arbitrary pulse programs. This object is implicitly initialized with the parameter object storage that stores parameter objects added to the parent pulse program. Parameter assignment logic is implemented based on the ...
unrolled_value_dict = self._unroll_param_dict(value_dict) valid_map = { k: unrolled_value_dict[k] for k in unrolled_value_dict.keys() & self._parameters } if valid_map: visitor = ParameterSetter(param_map=valid_map) return visitor.visit(pulse_program) ...
"""Modify and return program data with parameters assigned according to the input. Args: pulse_program: Arbitrary pulse program associated with this manager instance. value_dict: A mapping from Parameters to either numeric values or another Parameter expression. ...
24
995
114
1,109
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,604
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/parameter_manager.py
229,230
127,257
_assign_parameter_expression
ParameterSetter
231,238
230,238
class ParameterSetter(NodeVisitor): """Node visitor for parameter binding. This visitor is initialized with a dictionary of parameters to be assigned, and assign values to operands of nodes found. """ def __init__(self, param_map: dict[ParameterExpression, ParameterValueType]): self._param...
class ParameterSetter(NodeVisitor): """Node visitor for parameter binding. This visitor is initialized with a dictionary of parameters to be assigned, and assign values to operands of nodes found. """ def __init__(self, param_map: dict[ParameterExpression, ParameterValueType]): self._param...
new_value = copy(param_expr) updated = param_expr.parameters & self._param_map.keys() for param in updated: new_value = new_value.assign(param, self._param_map[param]) new_value = format_parameter_value(new_value) return new_value
"""A helper function to assign parameter value to parameter expression.""" new_value = copy(param_expr) updated = param_expr.parameters & self._param_map.keys() for param in updated: new_value = new_value.assign(param, self._param_map[param]) new_value = format_parame...
21
1,227
89
1,316
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,607
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/reference_manager.py
23,24
20,59
unassigned
ReferenceManager
29,35
24,35
class ReferenceManager(UserDict): """Dictionary wrapper to manage pulse schedule references.""" def unassigned(self) -> Tuple[Tuple[str, ...], ...]: FILL_FUNC_BODY def __setitem__(self, key, value): if key in self and self[key] is not None: # Check subroutine conflict. if sel...
class ReferenceManager(UserDict): """Dictionary wrapper to manage pulse schedule references.""" def unassigned(self) -> Tuple[Tuple[str, ...], ...]: """Get the keys of unassigned references. Returns: Tuple of reference keys. """ FILL_FUNC_BODY def __setitem__(self, key, ...
keys = [] for key, value in self.items(): if value is None: keys.append(key) return tuple(keys)
"""Get the keys of unassigned references. Returns: Tuple of reference keys. """ keys = [] for key, value in self.items(): if value is None: keys.append(key) return tuple(keys)
15
365
45
410
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,611
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/transforms/alignments.py
286,287
259,328
align
AlignEquispaced
298,328
287,328
class AlignEquispaced(AlignmentKind): """Align instructions with equispaced interval within a specified duration. Instructions played on different channels are also arranged in a sequence. This alignment is convenient to create dynamical decoupling sequences such as PDD. """ def __init__(self, dur...
class AlignEquispaced(AlignmentKind): """Align instructions with equispaced interval within a specified duration. Instructions played on different channels are also arranged in a sequence. This alignment is convenient to create dynamical decoupling sequences such as PDD. """ def __init__(self, dur...
instruction_duration_validation(self.duration) total_duration = sum(child.duration for _, child in schedule.children) if self.duration < total_duration: return schedule total_delay = self.duration - total_duration if len(schedule.children) > 1: # Calcul...
"""Reallocate instructions according to the policy. Only top-level sub-schedules are aligned. If sub-schedules are nested, nested schedules are not recursively aligned. Args: schedule: Schedule to align. Returns: Schedule with reallocated instructions. ...
108
331
316
647
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,612
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/transforms/alignments.py
379,380
328,407
align
AlignFunc
391,407
380,407
class AlignFunc(AlignmentKind): """Allocate instructions at position specified by callback function. The position is specified for each instruction of index ``j`` as a fractional coordinate in [0, 1] within the specified duration. Instructions played on different channels are also arranged in a sequen...
class AlignFunc(AlignmentKind): """Allocate instructions at position specified by callback function. The position is specified for each instruction of index ``j`` as a fractional coordinate in [0, 1] within the specified duration. Instructions played on different channels are also arranged in a sequen...
instruction_duration_validation(self.duration) if self.duration < schedule.duration: return schedule aligned = Schedule.initialize_from(schedule) for ind, (_, child) in enumerate(schedule.children): _t_center = self.duration * self.func(ind + 1) _t0 ...
"""Reallocate instructions according to the policy. Only top-level sub-schedules are aligned. If sub-schedules are nested, nested schedules are not recursively aligned. Args: schedule: Schedule to align. Returns: Schedule with reallocated instructions. ...
57
558
191
749
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,613
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/transforms/alignments.py
100,102
90,157
is_sequential
AlignLeft
102,104
102,104
class AlignLeft(AlignmentKind): """Align instructions in as-soon-as-possible manner. Instructions are placed at earliest available timeslots. """ def __init__(self): """Create new left-justified context.""" super().__init__(context_params=()) @property def is_sequential(self) ...
class AlignLeft(AlignmentKind): """Align instructions in as-soon-as-possible manner. Instructions are placed at earliest available timeslots. """ def __init__(self): """Create new left-justified context.""" super().__init__(context_params=()) @property def is_sequential(self) ...
return False
return False
2
636
7
643
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,614
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/transforms/alignments.py
171,172
157,225
align
AlignRight
183,189
172,189
class AlignRight(AlignmentKind): """Align instructions in as-late-as-possible manner. Instructions are placed at latest available timeslots. """ def __init__(self): """Create new right-justified context.""" super().__init__(context_params=()) @property def is_sequential(self) ...
class AlignRight(AlignmentKind): """Align instructions in as-late-as-possible manner. Instructions are placed at latest available timeslots. """ def __init__(self): """Create new right-justified context.""" super().__init__(context_params=()) @property def is_sequential(self) ...
aligned = Schedule.initialize_from(schedule) for _, child in reversed(schedule.children): aligned = self._push_right_prepend(aligned, child) return aligned
"""Reallocate instructions according to the policy. Only top-level sub-schedules are aligned. If sub-schedules are nested, nested schedules are not recursively aligned. Args: schedule: Schedule to align. Returns: Schedule with reallocated instructions. ...
14
559
58
617
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,615
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/transforms/alignments.py
240,241
225,259
align
AlignSequential
252,259
241,259
class AlignSequential(AlignmentKind): """Align instructions sequentially. Instructions played on different channels are also arranged in a sequence. No buffer time is inserted in between instructions. """ def __init__(self): """Create new sequential context.""" super().__init__(con...
class AlignSequential(AlignmentKind): """Align instructions sequentially. Instructions played on different channels are also arranged in a sequence. No buffer time is inserted in between instructions. """ def __init__(self): """Create new sequential context.""" super().__init__(con...
aligned = Schedule.initialize_from(schedule) for _, child in schedule.children: aligned.insert(aligned.duration, child, inplace=True) return aligned
"""Reallocate instructions according to the policy. Only top-level sub-schedules are aligned. If sub-schedules are nested, nested schedules are not recursively aligned. Args: schedule: Schedule to align. Returns: Schedule with reallocated instructions. ...
13
210
56
266
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,616
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/transforms/base_transforms.py
58,59
1,72
_format_schedule_component
60,72
59,72
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# TODO remove schedule initialization with *args, Qiskit-terra/#5093 try: sched = list(sched) # (t0, inst), or list of it if isinstance(sched[0], int): # (t0, inst) tuple return [tuple(sched)] else: return sched except TypeError: r...
"""A helper function to convert instructions into list of instructions.""" # TODO remove schedule initialization with *args, Qiskit-terra/#5093 try: sched = list(sched) # (t0, inst), or list of it if isinstance(sched[0], int): # (t0, inst) tuple return [tuple...
35
574
112
686
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,618
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/transforms/dag.py
93,94
1,116
_parallel_allocation
95,116
94,116
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
dag = rx.PyDAG() slots: dict[Channel, int] = {} edges: set[tuple[int, int]] = set() prev_reference = None for elm in block.blocks: node_id = dag.add_node(elm) try: for chan in elm.channels: prev_id = slots.pop(chan, prev_reference) if prev...
"""A helper function to create a DAG of a parallel alignment context.""" dag = rx.PyDAG() slots: dict[Channel, int] = {} edges: set[tuple[int, int]] = set() prev_reference = None for elm in block.blocks: node_id = dag.add_node(elm) try: for chan in elm.channels: ...
69
968
261
1,229
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,619
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/pulse/utils.py
43,47
1,151
format_parameter_value
56,99
47,99
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
if isinstance(operand, ParameterExpression): try: operand = operand.numeric() except TypeError: # Unassigned expression return operand # Return integer before calling the numpy round function. # The input value is multiplied by 10**decimals, rounds to an ...
"""Convert ParameterExpression into the most suitable data type. Args: operand: Operand value in arbitrary data type including ParameterExpression. decimal: Number of digit to round returned value. Returns: Value casted to non-parameter data type, when possible. """ if isin...
245
1,046
553
1,599
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,621
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/qobj/common.py
33,34
17,62
to_dict
QobjDictField
39,41
34,41
class QobjDictField(SimpleNamespace): """A class used to represent a dictionary field in Qobj Exists as a backwards compatibility shim around a dictionary for Qobjs previously constructed using marshmallow. """ def __init__(self, **kwargs): """Instantiate a new Qobj dict field object. ...
class QobjDictField(SimpleNamespace): """A class used to represent a dictionary field in Qobj Exists as a backwards compatibility shim around a dictionary for Qobjs previously constructed using marshmallow. """ def __init__(self, **kwargs): """Instantiate a new Qobj dict field object. ...
return self.__dict__
"""Return a dictionary format representation of the OpenQASM 2 Qobj. Returns: dict: The dictionary form of the QobjHeader. """ return self.__dict__
2
341
10
351
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,622
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/qobj/converters/lo_config.py
129,130
20,169
get_meas_los
LoConfigConverter
143,169
130,169
class LoConfigConverter: """This class supports to convert LoConfig into ~`lo_freq` attribute of configs. The format of LO frequency setup can be easily modified by replacing ``get_qubit_los`` and ``get_meas_los`` to align with your backend. """ def __init__( self, qobj_model, ...
class LoConfigConverter: """This class supports to convert LoConfig into ~`lo_freq` attribute of configs. The format of LO frequency setup can be easily modified by replacing ``get_qubit_los`` and ``get_meas_los`` to align with your backend. """ def __init__( self, qobj_model, ...
_m_los = None # try to use job level default values if self.meas_lo_freq: _m_los = self.meas_lo_freq.copy() # otherwise initialize list with ``None`` entries elif self.n_qubits: _m_los = [None] * self.n_qubits # fill experiment level LO's ...
"""Set experiment level meas LO frequencies. Use default values from job level if experiment level values not supplied. If experiment level and job level values not supplied, raise an error. If configured LO frequency is the same as default, this method returns ``None``. Args: ...
97
1,397
306
1,703
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,624
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/qobj/pulse_qobj.py
517,519
492,542
from_dict
PulseLibraryItem
527,529
519,529
class PulseLibraryItem: """An item in a pulse library.""" def __init__(self, name, samples): """Instantiate a pulse library item. Args: name (str): A name for the pulse. samples (list[complex]): A list of complex values defining pulse shape. """ ...
class PulseLibraryItem: """An item in a pulse library.""" def __init__(self, name, samples): """Instantiate a pulse library item. Args: name (str): A name for the pulse. samples (list[complex]): A list of complex values defining pulse shape. """ ...
return cls(**data)
"""Create a new PulseLibraryItem object from a dictionary. Args: data (dict): A dictionary for the experiment config Returns: PulseLibraryItem: The object from the input dictionary. """ return cls(**data)
2
411
12
423
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,625
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/qobj/pulse_qobj.py
626,628
542,656
from_dict
PulseQobj
637,651
628,651
class PulseQobj: """A Pulse Qobj.""" def __init__(self, qobj_id, config, experiments, header=None): """Instantiate a new Pulse Qobj Object. Each Pulse Qobj object is used to represent a single payload that will be passed to a Qiskit provider. It mirrors the Qobj the published `...
class PulseQobj: """A Pulse Qobj.""" def __init__(self, qobj_id, config, experiments, header=None): """Instantiate a new Pulse Qobj Object. Each Pulse Qobj object is used to represent a single payload that will be passed to a Qiskit provider. It mirrors the Qobj the published `...
config = None if "config" in data: config = PulseQobjConfig.from_dict(data["config"]) experiments = None if "experiments" in data: experiments = [PulseQobjExperiment.from_dict(exp) for exp in data["experiments"]] header = None if "header" in data: ...
"""Create a new PulseQobj object from a dictionary. Args: data (dict): A dictionary representing the PulseQobj to create. It will be in the same format as output by :func:`to_dict`. Returns: PulseQobj: The PulseQobj from the input dictionary. """...
41
1,040
159
1,199
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,626
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/qobj/pulse_qobj.py
362,364
282,379
from_dict
PulseQobjConfig
372,379
364,379
class PulseQobjConfig(QobjDictField): """A configuration for a Pulse Qobj.""" def __init__( self, meas_level, meas_return, pulse_library, qubit_lo_freq, meas_lo_freq, memory_slot_size=None, rep_time=None, rep_delay=None, shots=None...
class PulseQobjConfig(QobjDictField): """A configuration for a Pulse Qobj.""" def __init__( self, meas_level, meas_return, pulse_library, qubit_lo_freq, meas_lo_freq, memory_slot_size=None, rep_time=None, rep_delay=None, shots=None...
if "pulse_library" in data: pulse_lib = data.pop("pulse_library") pulse_lib_obj = [PulseLibraryItem.from_dict(x) for x in pulse_lib] data["pulse_library"] = pulse_lib_obj return cls(**data)
"""Create a new PulseQobjConfig object from a dictionary. Args: data (dict): A dictionary for the config Returns: PulseQobjConfig: The object from the input dictionary. """ if "pulse_library" in data: pulse_lib = data.pop("pulse_library") ...
19
966
87
1,053
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,627
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/qobj/pulse_qobj.py
443,445
379,473
from_dict
PulseQobjExperiment
453,466
445,466
class PulseQobjExperiment: """A Pulse Qobj Experiment. Each instance of this class is used to represent an individual Pulse experiment as part of a larger Pulse Qobj. """ def __init__(self, instructions, config=None, header=None): """Instantiate a PulseQobjExperiment. Args: ...
class PulseQobjExperiment: """A Pulse Qobj Experiment. Each instance of this class is used to represent an individual Pulse experiment as part of a larger Pulse Qobj. """ def __init__(self, instructions, config=None, header=None): """Instantiate a PulseQobjExperiment. Args: ...
config = None if "config" in data: config = PulseQobjExperimentConfig.from_dict(data.pop("config")) header = None if "header" in data: header = QobjExperimentHeader.from_dict(data.pop("header")) instructions = None if "instructions" in data: ...
"""Create a new PulseQobjExperiment object from a dictionary. Args: data (dict): A dictionary for the experiment config Returns: PulseQobjExperiment: The object from the input dictionary. """ config = None if "config" in data: config ...
40
803
145
948
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,628
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/qobj/pulse_qobj.py
183,184
73,265
to_dict
PulseQobjInstruction
189,199
184,199
class PulseQobjInstruction: """A class representing a single instruction in an PulseQobj Experiment.""" _COMMON_ATTRS = [ "ch", "conditional", "val", "phase", "frequency", "duration", "qubits", "memory_slot", "register_slot", "labe...
class PulseQobjInstruction: """A class representing a single instruction in an PulseQobj Experiment.""" _COMMON_ATTRS = [ "ch", "conditional", "val", "phase", "frequency", "duration", "qubits", "memory_slot", "register_slot", "labe...
out_dict = {"name": self.name, "t0": self.t0} for attr in self._COMMON_ATTRS: if hasattr(self, attr): out_dict[attr] = getattr(self, attr) if hasattr(self, "kernels"): out_dict["kernels"] = [x.to_dict() for x in self.kernels] if hasattr(self, "disc...
"""Return a dictionary format representation of the Instruction. Returns: dict: The dictionary form of the PulseQobjInstruction. """ out_dict = {"name": self.name, "t0": self.t0} for attr in self._COMMON_ATTRS: if hasattr(self, attr): out_...
39
1,718
160
1,878
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,629
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/qobj/pulse_qobj.py
53,55
28,73
from_dict
QobjMeasurementOption
63,66
55,66
class QobjMeasurementOption: """An individual measurement option.""" def __init__(self, name, params=None): """Instantiate a new QobjMeasurementOption object. Args: name (str): The name of the measurement option params (list): The parameters of the measurement option. ...
class QobjMeasurementOption: """An individual measurement option.""" def __init__(self, name, params=None): """Instantiate a new QobjMeasurementOption object. Args: name (str): The name of the measurement option params (list): The parameters of the measurement option. ...
name = data.pop("name") return cls(name, **data)
"""Create a new QobjMeasurementOption object from a dictionary. Args: data (dict): A dictionary for the experiment config Returns: QobjMeasurementOption: The object from the input dictionary. """ name = data.pop("name") return cls(name, **data)
6
328
25
353
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,630
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/qobj/qasm_qobj.py
517,518
487,543
to_dict
GateCalibration
523,527
518,527
class GateCalibration: """Each calibration specifies a unique gate by name, qubits and params, and contains the Pulse instructions to implement it.""" def __init__(self, name, qubits, params, instructions): """ Initialize a single gate calibration. Instructions may reference waveforms which...
class GateCalibration: """Each calibration specifies a unique gate by name, qubits and params, and contains the Pulse instructions to implement it.""" def __init__(self, name, qubits, params, instructions): """ Initialize a single gate calibration. Instructions may reference waveforms which...
out_dict = copy.copy(self.__dict__) out_dict["instructions"] = [x.to_dict() for x in self.instructions] return out_dict
"""Return a dictionary format representation of the Gate Calibration. Returns: dict: The dictionary form of the GateCalibration. """ out_dict = copy.copy(self.__dict__) out_dict["instructions"] = [x.to_dict() for x in self.instructions] return out_dict
12
454
50
504
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,631
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/qobj/qasm_qobj.py
471,473
446,487
from_dict
QasmExperimentCalibrations
482,487
473,487
class QasmExperimentCalibrations: """A container for any calibrations data. The gates attribute contains a list of GateCalibrations. """ def __init__(self, gates): """ Initialize a container for calibrations. Args: gates (list(GateCalibration)) """ s...
class QasmExperimentCalibrations: """A container for any calibrations data. The gates attribute contains a list of GateCalibrations. """ def __init__(self, gates): """ Initialize a container for calibrations. Args: gates (list(GateCalibration)) """ s...
gates = data.pop("gates") data["gates"] = [GateCalibration.from_dict(x) for x in gates] return cls(**data)
"""Create a new GateCalibration object from a dictionary. Args: data (dict): A dictionary representing the QasmExperimentCalibrations to create. It will be in the same format as output by :func:`to_dict`. Returns: QasmExperimentCalibrations: The...
12
310
53
363
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,632
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/qobj/qasm_qobj.py
590,591
543,657
to_dict
QasmQobj
617,627
591,627
class QasmQobj: """An OpenQASM 2 Qobj.""" def __init__(self, qobj_id=None, config=None, experiments=None, header=None): """Instantiate a new OpenQASM 2 Qobj Object. Each OpenQASM 2 Qobj object is used to represent a single payload that will be passed to a Qiskit provider. It mirrors th...
class QasmQobj: """An OpenQASM 2 Qobj.""" def __init__(self, qobj_id=None, config=None, experiments=None, header=None): """Instantiate a new OpenQASM 2 Qobj Object. Each OpenQASM 2 Qobj object is used to represent a single payload that will be passed to a Qiskit provider. It mirrors th...
out_dict = { "qobj_id": self.qobj_id, "header": self.header.to_dict(), "config": self.config.to_dict(), "schema_version": self.schema_version, "type": "QASM", "experiments": [x.to_dict() for x in self.experiments], } return ...
"""Return a dictionary format representation of the OpenQASM 2 Qobj. Note this dict is not in the json wire format expected by IBM and Qobj specification because complex numbers are still of type complex. Also, this may contain native numpy arrays. When serializing this output f...
22
1,121
112
1,233
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,633
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/qobj/qasm_qobj.py
378,380
278,406
from_dict
QasmQobjConfig
388,399
380,399
class QasmQobjConfig(SimpleNamespace): """A configuration for an OpenQASM 2 Qobj.""" def __init__( self, shots=None, seed_simulator=None, memory=None, parameter_binds=None, meas_level=None, meas_return=None, memory_slots=None, n_qubits=Non...
class QasmQobjConfig(SimpleNamespace): """A configuration for an OpenQASM 2 Qobj.""" def __init__( self, shots=None, seed_simulator=None, memory=None, parameter_binds=None, meas_level=None, meas_return=None, memory_slots=None, n_qubits=Non...
if "pulse_library" in data: pulse_lib = data.pop("pulse_library") pulse_lib_obj = [PulseLibraryItem.from_dict(x) for x in pulse_lib] data["pulse_library"] = pulse_lib_obj if "calibrations" in data: calibrations = data.pop("calibrations") data[...
"""Create a new QasmQobjConfig object from a dictionary. Args: data (dict): A dictionary for the config Returns: QasmQobjConfig: The object from the input dictionary. """ if "pulse_library" in data: pulse_lib = data.pop("pulse_library") ...
29
1,150
147
1,297
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,634
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/qobj/qasm_qobj.py
235,236
196,278
to_dict
QasmQobjExperiment
241,248
236,248
class QasmQobjExperiment: """An OpenQASM 2 Qobj Experiment. Each instance of this class is used to represent an OpenQASM 2 experiment as part of a larger OpenQASM 2 qobj. """ def __init__(self, config=None, header=None, instructions=None): """Instantiate a QasmQobjExperiment. Args...
class QasmQobjExperiment: """An OpenQASM 2 Qobj Experiment. Each instance of this class is used to represent an OpenQASM 2 experiment as part of a larger OpenQASM 2 qobj. """ def __init__(self, config=None, header=None, instructions=None): """Instantiate a QasmQobjExperiment. Args...
out_dict = { "config": self.config.to_dict(), "header": self.header.to_dict(), "instructions": [x.to_dict() for x in self.instructions], } return out_dict
"""Return a dictionary format representation of the Experiment. Returns: dict: The dictionary form of the QasmQObjExperiment. """ out_dict = { "config": self.config.to_dict(), "header": self.header.to_dict(), "instructions": [x.to_dict() f...
16
753
71
824
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,635
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/qobj/qasm_qobj.py
432,433
412,446
to_dict
QasmQobjExperimentConfig
433,438
433,438
class QasmQobjExperimentConfig(QobjDictField): """Configuration for a single OpenQASM 2 experiment in the qobj.""" def __init__(self, calibrations=None, qubit_lo_freq=None, meas_lo_freq=None, **kwargs): """ Args: calibrations (QasmExperimentCalibrations): Information required for Pu...
class QasmQobjExperimentConfig(QobjDictField): """Configuration for a single OpenQASM 2 experiment in the qobj.""" def __init__(self, calibrations=None, qubit_lo_freq=None, meas_lo_freq=None, **kwargs): """ Args: calibrations (QasmExperimentCalibrations): Information required for Pu...
out_dict = copy.copy(self.__dict__) if hasattr(self, "calibrations"): out_dict["calibrations"] = self.calibrations.to_dict() return out_dict
out_dict = copy.copy(self.__dict__) if hasattr(self, "calibrations"): out_dict["calibrations"] = self.calibrations.to_dict() return out_dict
11
366
64
430
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,636
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/qobj/qasm_qobj.py
176,178
23,196
from_dict
QasmQobjInstruction
186,189
178,189
class QasmQobjInstruction: """A class representing a single instruction in an QasmQobj Experiment.""" def __init__( self, name, params=None, qubits=None, register=None, memory=None, condition=None, conditional=None, label=None, mas...
class QasmQobjInstruction: """A class representing a single instruction in an QasmQobj Experiment.""" def __init__( self, name, params=None, qubits=None, register=None, memory=None, condition=None, conditional=None, label=None, mas...
name = data.pop("name") return cls(name, **data)
"""Create a new QasmQobjInstruction object from a dictionary. Args: data (dict): A dictionary for the experiment config Returns: QasmQobjInstruction: The object from the input dictionary. """ name = data.pop("name") return cls(name, **data)
6
1,449
25
1,474
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,640
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/quantum_info/analysis/average.py
22,23
1,48
average_data
40,48
23,48
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
if not isinstance(observable, dict): observable = make_dict_observable(observable) temp = 0 tot = sum(counts.values()) for key in counts: if key in observable: temp += counts[key] * observable[key] / tot return temp
"""Compute the mean value of an diagonal observable. Takes in a diagonal observable in dictionary, list or matrix format and then calculates the sum_i value(i) P(i) where value(i) is the value of the observable for state i. Args: counts (dict): a dict of outcomes from an experiment ...
30
462
83
545
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,641
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/quantum_info/analysis/distance.py
18,19
1,103
hellinger_distance
32,57
19,57
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
p_sum = sum(dist_p.values()) q_sum = sum(dist_q.values()) p_normed = {} for key, val in dist_p.items(): p_normed[key] = val / p_sum q_normed = {} for key, val in dist_q.items(): q_normed[key] = val / q_sum total = 0 for key, val in p_normed.items(): if key in q...
"""Computes the Hellinger distance between two counts distributions. Parameters: dist_p (dict): First dict of counts. dist_q (dict): Second dict of counts. Returns: float: Distance References: `Hellinger Distance @ wikipedia <https://en.wikipedia.org/wiki/Hellinger...
67
821
240
1,061
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,642
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/quantum_info/analysis/make_observable.py
20,21
1,45
make_dict_observable
34,45
21,45
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
dict_observable = {} observable = np.array(matrix_observable) observable_size = len(observable) observable_bits = math.ceil(math.log2(observable_size)) binary_formatter = f"0{observable_bits}b" if observable.ndim == 2: observable = observable.diagonal() for state_no in range(observab...
"""Convert an observable in matrix form to dictionary form. Takes in a diagonal observable as a matrix and converts it to a dictionary form. Can also handle a list sorted of the diagonal elements. Args: matrix_observable (list): The observable to be converted to dictionary form. Can be...
35
328
156
484
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,645
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/quantum_info/operators/base_operator.py
143,144
27,146
copy
BaseOperator
145,146
144,146
class BaseOperator(GroupMixin, ABC): """Abstract operator base class.""" def __init__( self, input_dims: tuple | int | None = None, output_dims: tuple | int | None = None, num_qubits: int | None = None, shape: tuple | None = None, op_shape: OpShape | None = None,...
class BaseOperator(GroupMixin, ABC): """Abstract operator base class.""" def __init__( self, input_dims: tuple | int | None = None, output_dims: tuple | int | None = None, num_qubits: int | None = None, shape: tuple | None = None, op_shape: OpShape | None = None,...
return copy.deepcopy(self)
"""Make a deep copy of current operator.""" return copy.deepcopy(self)
2
1,199
11
1,210
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,646
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/quantum_info/operators/channel/chi.py
163,164
35,191
compose
Chi
164,172
164,172
class Chi(QuantumChannel): r"""Pauli basis Chi-matrix representation of a quantum channel. The Chi-matrix representation of an :math:`n`-qubit quantum channel :math:`\mathcal{E}` is a matrix :math:`\chi` such that the evolution of a :class:`~qiskit.quantum_info.DensityMatrix` :math:`\rho` is given by ...
class Chi(QuantumChannel): r"""Pauli basis Chi-matrix representation of a quantum channel. The Chi-matrix representation of an :math:`n`-qubit quantum channel :math:`\mathcal{E}` is a matrix :math:`\chi` such that the evolution of a :class:`~qiskit.quantum_info.DensityMatrix` :math:`\rho` is given by ...
if qargs is None: qargs = getattr(other, "qargs", None) if qargs is not None: return Chi(SuperOp(self).compose(other, qargs=qargs, front=front)) # If no qargs we compose via Choi representation to avoid an additional # representation conversion to SuperOp and then...
if qargs is None: qargs = getattr(other, "qargs", None) if qargs is not None: return Chi(SuperOp(self).compose(other, qargs=qargs, front=front)) # If no qargs we compose via Choi representation to avoid an additional # representation conversion to SuperOp and then...
45
1,783
118
1,901
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,650
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/quantum_info/operators/channel/ptm.py
195,197
34,204
_tensor
PTM
197,204
197,204
class PTM(QuantumChannel): r"""Pauli Transfer Matrix (PTM) representation of a Quantum Channel. The PTM representation of an :math:`n`-qubit quantum channel :math:`\mathcal{E}` is an :math:`n`-qubit :class:`SuperOp` :math:`R` defined with respect to vectorization in the Pauli basis instead of colum...
class PTM(QuantumChannel): r"""Pauli Transfer Matrix (PTM) representation of a Quantum Channel. The PTM representation of an :math:`n`-qubit quantum channel :math:`\mathcal{E}` is an :math:`n`-qubit :class:`SuperOp` :math:`R` defined with respect to vectorization in the Pauli basis instead of colum...
ret = _copy.copy(a) ret._op_shape = a._op_shape.tensor(b._op_shape) ret._data = np.kron(a._data, b.data) return ret # Update docstrings for API docs
ret = _copy.copy(a) ret._op_shape = a._op_shape.tensor(b._op_shape) ret._data = np.kron(a._data, b.data) return ret # Update docstrings for API docs
18
1,966
74
2,040
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,658
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/quantum_info/operators/dihedral/random.py
22,23
1,64
random_cnotdihedral
32,64
23,64
# This code is part of Qiskit. # # (C) Copyright IBM 2019, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2019, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
if seed is None: rng = np.random.default_rng() elif isinstance(seed, np.random.Generator): rng = seed else: rng = default_rng(seed) elem = CNOTDihedral(num_qubits=num_qubits) # Random phase polynomial weights weight_1 = rng.integers(8, size=num_qubits) elem.poly.we...
"""Return a random CNOTDihedral element. Args: num_qubits (int): the number of qubits for the CNOTDihedral object. seed (int or RandomState): Optional. Set a fixed seed or generator for RNG. Returns: CNOTDihedral: a random CNOTDihedral element. ...
103
303
391
694
# This code is part of Qiskit. # # (C) Copyright IBM 2019, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2019, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,660
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/quantum_info/operators/mixins/adjoint.py
42,43
26,53
adjoint
AdjointMixin
44,46
43,46
class AdjointMixin(ABC): """Abstract Mixin for operator adjoint and transpose operations. This class defines the following methods - :meth:`transpose` - :meth:`conjugate` - :meth:`adjoint` The following abstract methods must be implemented by subclasses using this mixin ...
class AdjointMixin(ABC): """Abstract Mixin for operator adjoint and transpose operations. This class defines the following methods - :meth:`transpose` - :meth:`conjugate` - :meth:`adjoint` The following abstract methods must be implemented by subclasses using this mixin ...
return self.conjugate().transpose()
"""Return the adjoint of the CLASS.""" return self.conjugate().transpose()
2
206
15
221
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,661
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/quantum_info/operators/mixins/group.py
67,69
29,172
tensor
GroupMixin
69,87
69,87
class GroupMixin(ABC): """Abstract Mixin for operator group operations. This class defines the following methods - :meth:`compose` - :meth:`dot` - :meth:`tensor` - :meth:`expand` - :meth:`power` And the following operator overloads: - ``&``, ``__and__`` ->...
class GroupMixin(ABC): """Abstract Mixin for operator group operations. This class defines the following methods - :meth:`compose` - :meth:`dot` - :meth:`tensor` - :meth:`expand` - :meth:`power` And the following operator overloads: - ``&``, ``__and__`` ->...
r"""Return the tensor product with another CLASS. Args: other (CLASS): a CLASS object. Returns: CLASS: the tensor product :math:`a \otimes b`, where :math:`a` is the current CLASS, and :math:`b` is the other CLASS. .. note:: The tens...
r"""Return the tensor product with another CLASS. Args: other (CLASS): a CLASS object. Returns: CLASS: the tensor product :math:`a \otimes b`, where :math:`a` is the current CLASS, and :math:`b` is the other CLASS. .. note:: The tens...
74
1,240
189
1,429
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,662
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/quantum_info/operators/mixins/tolerances.py
54,56
22,61
rtol
TolerancesMeta
57,61
56,61
class TolerancesMeta(ABCMeta): """Metaclass to handle tolerances""" def __init__(cls, *args, **kwargs): cls._ATOL_DEFAULT = ATOL_DEFAULT cls._RTOL_DEFAULT = RTOL_DEFAULT cls._MAX_TOL = 1e-4 super().__init__(cls, args, kwargs) def _check_value(cls, value, value_name): ...
class TolerancesMeta(ABCMeta): """Metaclass to handle tolerances""" def __init__(cls, *args, **kwargs): cls._ATOL_DEFAULT = ATOL_DEFAULT cls._RTOL_DEFAULT = RTOL_DEFAULT cls._MAX_TOL = 1e-4 super().__init__(cls, args, kwargs) def _check_value(cls, value, value_name): ...
cls._check_value(value, "rtol") # pylint: disable=no-value-for-parameter cls._RTOL_DEFAULT = value
"""Set default relative tolerance parameter for float comparisons.""" cls._check_value(value, "rtol") # pylint: disable=no-value-for-parameter cls._RTOL_DEFAULT = value
8
388
47
435
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,663
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/quantum_info/operators/mixins/tolerances.py
69,71
61,73
rtol
TolerancesMixin
72,73
71,73
class TolerancesMixin(metaclass=TolerancesMeta): """Mixin Class for tolerances""" @property def atol(self): """Default absolute tolerance parameter for float comparisons.""" return self.__class__.atol @property def rtol(self): FILL_FUNC_BODY
class TolerancesMixin(metaclass=TolerancesMeta): """Mixin Class for tolerances""" @property def atol(self): """Default absolute tolerance parameter for float comparisons.""" return self.__class__.atol @property def rtol(self): """Default relative tolerance parameter for flo...
return self.__class__.rtol
"""Default relative tolerance parameter for float comparisons.""" return self.__class__.rtol
2
98
11
109
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,665
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/quantum_info/operators/predicates.py
148,149
1,183
is_identity_matrix
150,168
149,168
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
if atol is None: atol = ATOL_DEFAULT if rtol is None: rtol = RTOL_DEFAULT mat = np.array(mat) if mat.ndim != 2: return False if ignore_phase: # If the matrix is equal to an identity up to a phase, we can # remove the phase by multiplying each entry by the comp...
"""Test if an array is an identity matrix.""" if atol is None: atol = ATOL_DEFAULT if rtol is None: rtol = RTOL_DEFAULT mat = np.array(mat) if mat.ndim != 2: return False if ignore_phase: # If the matrix is equal to an identity up to a phase, we can # remo...
85
1,756
217
1,973
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,666
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/quantum_info/operators/random.py
59,62
1,155
random_hermitian
77,105
62,105
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
if seed is None: rng = DEFAULT_RNG elif isinstance(seed, np.random.Generator): rng = seed else: rng = default_rng(seed) # Total dimension dim = np.prod(dims) from scipy import stats if traceless: mat = np.zeros((dim, dim), dtype=complex) else: # ...
"""Return a random hermitian Operator. The operator is sampled from Gaussian Unitary Ensemble. Args: dims (int or tuple): the input dimension of the Operator. traceless (bool): Optional. If True subtract diagonal entries to return a traceless hermitian operator ...
108
1,263
396
1,659
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,673
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/quantum_info/operators/symplectic/pauli_utils.py
21,22
1,41
pauli_basis
32,41
22,41
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2020 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivati...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2020 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivati...
pauli_1q = PauliList(["I", "X", "Y", "Z"]) if num_qubits == 1: return pauli_1q pauli = pauli_1q for _ in range(num_qubits - 1): pauli = pauli_1q.tensor(pauli) if weight: return pauli.sort(weight=True) return pauli
"""Return the ordered PauliList for the n-qubit Pauli basis. Args: num_qubits (int): number of qubits weight (bool): if True optionally return the basis sorted by Pauli weight rather than lexicographic order (Default: False) Returns: PauliList: the Paulis for...
30
314
115
429
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2020 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivati...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2020 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivati...
30,675
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/quantum_info/operators/utils/anti_commutator.py
23,24
1,37
anti_commutator
24,37
24,37
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
r"""Compute anti-commutator of a and b. .. math:: ab + ba. Args: a: Operator a. b: Operator b. Returns: The anti-commutator """ return a @ b + b @ a
r"""Compute anti-commutator of a and b. .. math:: ab + ba. Args: a: Operator a. b: Operator b. Returns: The anti-commutator """ return a @ b + b @ a
30
239
89
328
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,676
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/quantum_info/operators/utils/commutator.py
23,24
1,37
commutator
24,37
24,37
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
r"""Compute commutator of a and b. .. math:: ab - ba. Args: a: Operator a. b: Operator b. Returns: The commutator """ return a @ b - b @ a
r"""Compute commutator of a and b. .. math:: ab - ba. Args: a: Operator a. b: Operator b. Returns: The commutator """ return a @ b - b @ a
30
235
83
318
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,677
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/quantum_info/operators/utils/double_commutator.py
23,26
1,77
double_commutator
26,77
26,77
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
r"""Compute symmetric double commutator of a, b and c. See also Equation (13.6.18) in [1]. If `commutator` is `True`, it returns .. math:: [[A, B], C]/2 + [A, [B, C]]/2 = (2ABC + 2CBA - BAC - CAB - ACB - BCA)/2. If `commutator` is `False`, it returns .. math:: \l...
r"""Compute symmetric double commutator of a, b and c. See also Equation (13.6.18) in [1]. If `commutator` is `True`, it returns .. math:: [[A, B], C]/2 + [A, [B, C]]/2 = (2ABC + 2CBA - BAC - CAB - ACB - BCA)/2. If `commutator` is `False`, it returns .. math:: \l...
193
257
510
767
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2023. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,678
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/quantum_info/quaternion.py
73,74
21,157
to_matrix
Quaternion
79,90
74,90
class Quaternion: """A class representing a Quaternion.""" def __init__(self, data): self.data = np.asarray(data, dtype=float) def __call__(self, idx): return self.data[idx] def __repr__(self): return np.array_str(self.data) def __str__(self): return np.array_str(...
class Quaternion: """A class representing a Quaternion.""" def __init__(self, data): self.data = np.asarray(data, dtype=float) def __call__(self, idx): return self.data[idx] def __repr__(self): return np.array_str(self.data) def __str__(self): return np.array_str(...
w, x, y, z = self.normalize().data mat = np.array( [ [1 - 2 * y**2 - 2 * z**2, 2 * x * y - 2 * z * w, 2 * x * z + 2 * y * w], [2 * x * y + 2 * z * w, 1 - 2 * x**2 - 2 * z**2, 2 * y * z - 2 * x * w], [2 * x * z - 2 * y * w, 2 * y * z + 2 * x * w...
"""Converts a unit-length quaternion to a rotation matrix. Returns: ndarray: Rotation matrix. """ w, x, y, z = self.normalize().data mat = np.array( [ [1 - 2 * y**2 - 2 * z**2, 2 * x * y - 2 * z * w, 2 * x * z + 2 * y * w], ...
108
1,368
194
1,562
# This code is part of Qiskit. # # (C) Copyright IBM 2017. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2017. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,681
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/quantum_info/states/random.py
29,32
1,158
random_statevector
49,63
32,63
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
if seed is None: rng = np.random.default_rng() elif isinstance(seed, np.random.Generator): rng = seed else: rng = default_rng(seed) dim = np.prod(dims) vec = rng.standard_normal(dim).astype(complex) vec += 1j * rng.standard_normal(dim) vec /= np.linalg.norm(vec) ...
"""Generator a random Statevector. The statevector is sampled from the uniform distribution. This is the measure induced by the Haar measure on unitary matrices. Args: dims (int or tuple): the dimensions of the state. seed (int or np.random.Generator): Optional. Set a fixed seed or ...
34
1,429
151
1,580
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,684
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/result/counts.py
182,184
27,190
_remove_space_underscore
Counts
185,187
184,187
class Counts(dict): """A class to store a counts result from a circuit execution.""" bitstring_regex = re.compile(r"^[01\s]+$") def __init__(self, data, time_taken=None, creg_sizes=None, memory_slots=None): """Build a counts object Args: data (dict): The dictionary input for t...
class Counts(dict): """A class to store a counts result from a circuit execution.""" bitstring_regex = re.compile(r"^[01\s]+$") def __init__(self, data, time_taken=None, creg_sizes=None, memory_slots=None): """Build a counts object Args: data (dict): The dictionary input for t...
return int(bitstring.replace(" ", "").replace("_", ""), 2)
"""Removes all spaces and underscores from bitstring""" return int(bitstring.replace(" ", "").replace("_", ""), 2)
6
1,814
25
1,839
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,685
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/result/distributions/probability.py
75,76
23,101
binary_probabilities
ProbDistribution
90,93
76,93
class ProbDistribution(dict): """A generic dict-like class for probability distributions.""" _bitstring_regex = re.compile(r"^[01]+$") def __init__(self, data, shots=None): """Builds a probability distribution object. Args: data (dict): Input probability data. Where the keys ...
class ProbDistribution(dict): """A generic dict-like class for probability distributions.""" _bitstring_regex = re.compile(r"^[01]+$") def __init__(self, data, shots=None): """Builds a probability distribution object. Args: data (dict): Input probability data. Where the keys ...
n = self._num_bits if num_bits is None else num_bits return {format(key, "b").zfill(n): value for key, value in self.items()}
"""Build a probabilities dictionary with binary string keys Parameters: num_bits (int): number of bits in the binary bitstrings (leading zeros will be padded). If None, a default value will be used. If keys are given as integers or strings with binary or hex ...
18
874
50
924
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,686
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/result/distributions/quasi.py
88,89
26,155
nearest_probability_distribution
QuasiDistribution
103,121
89,121
class QuasiDistribution(dict): """A dict-like class for representing quasi-probabilities.""" _bitstring_regex = re.compile(r"^[01]+$") __ndigits__ = 15 def __init__(self, data, shots=None, stddev_upper_bound=None): """Builds a quasiprobability distribution object. .. note:: ...
class QuasiDistribution(dict): """A dict-like class for representing quasi-probabilities.""" _bitstring_regex = re.compile(r"^[01]+$") __ndigits__ = 15 def __init__(self, data, shots=None, stddev_upper_bound=None): """Builds a quasiprobability distribution object. .. note:: ...
sorted_probs = dict(sorted(self.items(), key=lambda item: item[1])) num_elems = len(sorted_probs) new_probs = {} beta = 0 diff = 0 for key, val in sorted_probs.items(): temp = val + beta / num_elems if temp < 0: beta += val ...
"""Takes a quasiprobability distribution and maps it to the closest probability distribution as defined by the L2-norm. Parameters: return_distance (bool): Return the L2 distance between distributions. Returns: ProbDistribution: Nearest probability distr...
71
1,305
224
1,529
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,689
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/result/mitigation/utils.py
99,102
1,163
remap_qubits
103,111
102,111
# This code is part of Qiskit. # # (C) Copyright IBM 2021 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wor...
# This code is part of Qiskit. # # (C) Copyright IBM 2021 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wor...
if qubits is not None: if len(qubits) != num_qubits: raise QiskitError("Num qubits does not match vector length.") axes = [num_qubits - 1 - i for i in reversed(np.argsort(qubits))] vec = np.reshape(vec, num_qubits * [2]).transpose(axes).reshape(vec.shape) return vec
"""Remapping the qubits""" if qubits is not None: if len(qubits) != num_qubits: raise QiskitError("Num qubits does not match vector length.") axes = [num_qubits - 1 - i for i in reversed(np.argsort(qubits))] vec = np.reshape(vec, num_qubits * [2]).transpose(axes).reshape(vec....
36
1,639
120
1,759
# This code is part of Qiskit. # # (C) Copyright IBM 2021 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wor...
# This code is part of Qiskit. # # (C) Copyright IBM 2021 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wor...
30,690
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/result/models.py
189,190
99,234
to_dict
ExperimentResult
195,212
190,212
class ExperimentResult: """Class representing an Experiment Result. Attributes: shots (int or tuple): the starting and ending shot for this data. success (bool): if true, we can trust results for this experiment. data (ExperimentResultData): results information. meas_level (int)...
class ExperimentResult: """Class representing an Experiment Result. Attributes: shots (int or tuple): the starting and ending shot for this data. success (bool): if true, we can trust results for this experiment. data (ExperimentResultData): results information. meas_level (int)...
out_dict = { "shots": self.shots, "success": self.success, "data": self.data.to_dict(), "meas_level": self.meas_level, } if hasattr(self, "header"): out_dict["header"] = self.header.to_dict() if hasattr(self, "status"): ...
"""Return a dictionary format representation of the ExperimentResult Returns: dict: The dictionary form of the ExperimentResult """ out_dict = { "shots": self.shots, "success": self.success, "data": self.data.to_dict(), "meas_l...
39
1,103
202
1,305
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,691
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/result/models.py
83,85
22,99
from_dict
ExperimentResultData
95,99
85,99
class ExperimentResultData: """Class representing experiment result data""" def __init__( self, counts=None, snapshots=None, memory=None, statevector=None, unitary=None, **kwargs ): """Initialize an ExperimentalResult Data class Args: counts (dict): A dictionary where t...
class ExperimentResultData: """Class representing experiment result data""" def __init__( self, counts=None, snapshots=None, memory=None, statevector=None, unitary=None, **kwargs ): """Initialize an ExperimentalResult Data class Args: counts (dict): A dictionary where t...
in_data = copy.copy(data) return cls(**in_data)
"""Create a new ExperimentResultData object from a dictionary. Args: data (dict): A dictionary representing the ExperimentResultData to create. It will be in the same format as output by :meth:`to_dict` Returns: Experimen...
5
707
29
736
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2018. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,696
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/scheduler/methods/basic.py
28,33
1,138
as_soon_as_possible
52,81
33,81
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
qubit_time_available = defaultdict(int) def update_times(inst_qubits: List[int], time: int = 0) -> None: """Update the time tracker for all inst_qubits to the given time.""" for q in inst_qubits: qubit_time_available[q] = time start_times = [] circ_pulse_defs = lower_gates(...
""" Return the pulse Schedule which implements the input circuit using an "as soon as possible" (asap) scheduling policy. Circuit instructions are first each mapped to equivalent pulse Schedules according to the command definition given by the schedule_config. Then, this circuit instruction-equ...
91
1,226
382
1,608
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,697
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/scheduler/schedule_circuit.py
25,31
1,68
schedule_circuit
56,68
31,68
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
methods = { "as_soon_as_possible": as_soon_as_possible, "asap": as_soon_as_possible, "as_late_as_possible": as_late_as_possible, "alap": as_late_as_possible, } if method is None: method = "as_late_as_possible" try: return methods[method](circuit, schedule_...
""" Basic scheduling pass from a circuit to a pulse Schedule, using the backend. If no method is specified, then a basic, as late as possible scheduling pass is performed, i.e. pulses are scheduled to occur as late as possible. Supported methods: * ``'as_soon_as_possible'``: Schedule pulse...
36
600
157
757
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,698
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/scheduler/sequence.py
30,35
1,103
sequence
53,103
35,103
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
circ_pulse_defs = lower_gates(scheduled_circuit, schedule_config, backend) # find the measurement start time (assume measurement once) def _meas_start_time(): _qubit_time_available = defaultdict(int) for instruction in scheduled_circuit.data: if isinstance(instruction.operation,...
""" Return the pulse Schedule which implements the input scheduled circuit. Assume all measurements are done at once at the last of the circuit. Schedules according to the command definition given by the schedule_config. Args: scheduled_circuit: The scheduled quantum circuit to translate. ...
168
524
700
1,224
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,699
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/clifford/clifford_decompose_ag.py
88,89
1,179
_set_qubit_x_true
94,118
89,118
# This code is part of Qiskit. # # (C) Copyright IBM 2021, 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2021, 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
x = clifford.destab_x[qubit] z = clifford.destab_z[qubit] if x[qubit]: return # Try to find non-zero element for i in range(qubit + 1, clifford.num_qubits): if x[i]: _append_swap(clifford, i, qubit) circuit.swap(i, qubit) return # no non-zer...
"""Set destabilizer.X[qubit, qubit] to be True. This is done by permuting columns l > qubit or if necessary applying a Hadamard """ x = clifford.destab_x[qubit] z = clifford.destab_z[qubit] if x[qubit]: return # Try to find non-zero element for i in range(qubit + 1, cliffo...
60
1,753
243
1,996
# This code is part of Qiskit. # # (C) Copyright IBM 2021, 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2021, 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,701
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/clifford/clifford_decompose_full.py
24,25
1,65
synth_clifford_full
25,65
25,65
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2022 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivati...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2022 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivati...
r"""Decompose a :class:`.Clifford` operator into a :class:`.QuantumCircuit`. For :math:`N \leq 3` qubits this is based on optimal CX-cost decomposition from reference [1]. For :math:`N > 3` qubits this is done using the general non-optimal greedy compilation routine from reference [3], which typica...
r"""Decompose a :class:`.Clifford` operator into a :class:`.QuantumCircuit`. For :math:`N \leq 3` qubits this is based on optimal CX-cost decomposition from reference [1]. For :math:`N > 3` qubits this is done using the general non-optimal greedy compilation routine from reference [3], which typica...
165
341
630
971
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2022 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivati...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2022 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivati...
30,704
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_full.py
25,26
1,53
synth_cnotdihedral_full
26,53
26,53
# This code is part of Qiskit. # # (C) Copyright IBM 2019, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2019, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
r"""Decompose a :class:`.CNOTDihedral` element into a :class:`.QuantumCircuit`. For :math:`N \leq 2` qubits this is based on optimal CX-cost decomposition from reference [1]. For :math:`N > 2` qubits this is done using the general non-optimal compilation routine from reference [2]. Args: e...
r"""Decompose a :class:`.CNOTDihedral` element into a :class:`.QuantumCircuit`. For :math:`N \leq 2` qubits this is based on optimal CX-cost decomposition from reference [1]. For :math:`N > 2` qubits this is done using the general non-optimal compilation routine from reference [2]. Args: e...
115
313
397
710
# This code is part of Qiskit. # # (C) Copyright IBM 2019, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2019, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,705
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/cnotdihedral/cnotdihedral_decompose_general.py
22,23
1,142
synth_cnotdihedral_general
44,142
23,142
# This code is part of Qiskit. # # (C) Copyright IBM 2019, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2019, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
num_qubits = elem.num_qubits circuit = QuantumCircuit(num_qubits) # Make a copy of the CNOTDihedral element as we are going to # reduce it to an identity elem_cpy = elem.copy() if not np.allclose((np.linalg.det(elem_cpy.linear) % 2), 1): raise QiskitError("Linear part is not invertibl...
"""Decompose a :class:`.CNOTDihedral` element into a :class:`.QuantumCircuit`. Decompose a general :class:`.CNOTDihedral` elements. The number of CX gates is not necessarily optimal. For a decomposition of a 1-qubit or 2-qubit element, call :func:`.synth_cnotdihedral_two_qubits`. Args: ...
378
503
1,435
1,938
# This code is part of Qiskit. # # (C) Copyright IBM 2019, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2019, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,710
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/discrete_basis/generate_basis_approximations.py
121,124
1,164
generate_basic_approximations
137,164
124,164
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
basis = [] for gate in basis_gates: if isinstance(gate, str): if gate not in _1q_gates.keys(): raise ValueError(f"Invalid gate identifier: {gate}") basis.append(gate) else: # gate is a qiskit.circuit.Gate basis.append(gate.name) tree = No...
"""Generates a list of :class:`GateSequence`\\ s with the gates in ``basis_gates``. Args: basis_gates: The gates from which to create the sequences of gates. depth: The maximum depth of the approximations. filename: If provided, the basic approximations are stored in this file. Ret...
80
1,427
264
1,691
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2024. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,712
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/discrete_basis/solovay_kitaev.py
88,95
26,178
run
SolovayKitaevDecomposition
95,129
95,129
class SolovayKitaevDecomposition: """The Solovay Kitaev discrete decomposition algorithm. This class is called recursively by the transpiler pass, which is why it is separeted. See :class:`qiskit.transpiler.passes.SolovayKitaev` for more information. """ def __init__( self, basic_approxima...
class SolovayKitaevDecomposition: """The Solovay Kitaev discrete decomposition algorithm. This class is called recursively by the transpiler pass, which is why it is separeted. See :class:`qiskit.transpiler.passes.SolovayKitaev` for more information. """ def __init__( self, basic_approxima...
r"""Run the algorithm. Args: gate_matrix: The 2x2 matrix representing the gate. This matrix has to be SU(2) up to global phase. recursion_degree: The recursion degree, called :math:`n` in the paper. return_dag: If ``True`` return a :class:`.DAGCircuit...
r"""Run the algorithm. Args: gate_matrix: The 2x2 matrix representing the gate. This matrix has to be SU(2) up to global phase. recursion_degree: The recursion degree, called :math:`n` in the paper. return_dag: If ``True`` return a :class:`.DAGCircuit...
132
1,458
422
1,880
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,713
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/evolution/evolution_synthesis.py
34,36
19,47
settings
EvolutionSynthesis
44,47
36,47
class EvolutionSynthesis(ABC): """Interface for evolution synthesis algorithms.""" @abstractmethod def synthesize(self, evolution): """Synthesize an ``qiskit.circuit.library.PauliEvolutionGate``. Args: evolution (PauliEvolutionGate): The evolution gate to synthesize. R...
class EvolutionSynthesis(ABC): """Interface for evolution synthesis algorithms.""" @abstractmethod def synthesize(self, evolution): """Synthesize an ``qiskit.circuit.library.PauliEvolutionGate``. Args: evolution (PauliEvolutionGate): The evolution gate to synthesize. R...
raise NotImplementedError( "The settings property is not implemented for the base interface." )
"""Return the settings in a dictionary, which can be used to reconstruct the object. Returns: A dictionary containing the settings of this product formula. Raises: NotImplementedError: The interface does not implement this method. """ raise NotImplemente...
13
210
29
239
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,714
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/evolution/lie_trotter.py
72,73
23,117
synthesize
LieTrotter
73,97
73,97
class LieTrotter(ProductFormula): r"""The Lie-Trotter product formula. The Lie-Trotter formula approximates the exponential of two non-commuting operators with products of their exponentials up to a second order error: .. math:: e^{A + B} \approx e^{A}e^{B}. In this implementation, the o...
class LieTrotter(ProductFormula): r"""The Lie-Trotter product formula. The Lie-Trotter formula approximates the exponential of two non-commuting operators with products of their exponentials up to a second order error: .. math:: e^{A + B} \approx e^{A}e^{B}. In this implementation, the o...
# get operators and time to evolve operators = evolution.operator time = evolution.time # construct the evolution circuit evolution_circuit = QuantumCircuit(operators[0].num_qubits) if not isinstance(operators, list): pauli_list = [(Pauli(op), np.real(coeff)...
# get operators and time to evolve operators = evolution.operator time = evolution.time # construct the evolution circuit evolution_circuit = QuantumCircuit(operators[0].num_qubits) if not isinstance(operators, list): pauli_list = [(Pauli(op), np.real(coeff)...
95
801
311
1,112
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,715
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/evolution/matrix_synthesis.py
29,30
20,48
synthesize
MatrixExponential
30,48
30,48
class MatrixExponential(EvolutionSynthesis): r"""Exact operator evolution via matrix exponentiation and unitary synthesis. This class synthesis the exponential of operators by calculating their exponentially-sized matrix representation and using exact matrix exponentiation followed by unitary synthesis ...
class MatrixExponential(EvolutionSynthesis): r"""Exact operator evolution via matrix exponentiation and unitary synthesis. This class synthesis the exponential of operators by calculating their exponentially-sized matrix representation and using exact matrix exponentiation followed by unitary synthesis ...
# pylint: disable=cyclic-import from qiskit.circuit.library.hamiltonian_gate import HamiltonianGate # get operators and time to evolve operators = evolution.operator time = evolution.time if not isinstance(operators, list): matrix = operators.to_matrix() ...
# pylint: disable=cyclic-import from qiskit.circuit.library.hamiltonian_gate import HamiltonianGate # get operators and time to evolve operators = evolution.operator time = evolution.time if not isinstance(operators, list): matrix = operators.to_matrix() ...
51
109
191
300
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,717
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/evolution/product_formula.py
68,70
25,91
settings
ProductFormula
78,91
70,91
class ProductFormula(EvolutionSynthesis): """Product formula base class for the decomposition of non-commuting operator exponentials. :obj:`.LieTrotter` and :obj:`.SuzukiTrotter` inherit from this class. """ def __init__( self, order: int, reps: int = 1, insert_barriers...
class ProductFormula(EvolutionSynthesis): """Product formula base class for the decomposition of non-commuting operator exponentials. :obj:`.LieTrotter` and :obj:`.SuzukiTrotter` inherit from this class. """ def __init__( self, order: int, reps: int = 1, insert_barriers...
if self._atomic_evolution is not None: raise NotImplementedError( "Cannot serialize a product formula with a custom atomic evolution." ) return { "order": self.order, "reps": self.reps, "insert_barriers": self.insert_barriers, ...
"""Return the settings in a dictionary, which can be used to reconstruct the object. Returns: A dictionary containing the settings of this product formula. Raises: NotImplementedError: If a custom atomic evolution is set, which cannot be serialized. """ ...
29
560
113
673
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,718
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/evolution/qdrift.py
61,62
25,102
synthesize
QDrift
62,102
62,102
class QDrift(ProductFormula): r"""The QDrift Trotterization method, which selects each each term in the Trotterization randomly, with a probability proportional to its weight. Based on the work of Earl Campbell in Ref. [1]. References: [1]: E. Campbell, "A random compiler for fast Hamiltonian s...
class QDrift(ProductFormula): r"""The QDrift Trotterization method, which selects each each term in the Trotterization randomly, with a probability proportional to its weight. Based on the work of Earl Campbell in Ref. [1]. References: [1]: E. Campbell, "A random compiler for fast Hamiltonian s...
# get operators and time to evolve operators = evolution.operator time = evolution.time if not isinstance(operators, list): pauli_list = [(Pauli(op), coeff) for op, coeff in operators.to_list()] coeffs = [np.real(coeff) for op, coeff in operators.to_list()] ...
# get operators and time to evolve operators = evolution.operator time = evolution.time if not isinstance(operators, list): pauli_list = [(Pauli(op), coeff) for op, coeff in operators.to_list()] coeffs = [np.real(coeff) for op, coeff in operators.to_list()] ...
150
488
513
1,001
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,719
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/evolution/suzuki_trotter.py
127,129
26,146
_recurse
SuzukiTrotter
129,146
129,146
class SuzukiTrotter(ProductFormula): r"""The (higher order) Suzuki-Trotter product formula. The Suzuki-Trotter formulas improve the error of the Lie-Trotter approximation. For example, the second order decomposition is .. math:: e^{A + B} \approx e^{B/2} e^{A} e^{B/2}. Higher order decom...
class SuzukiTrotter(ProductFormula): r"""The (higher order) Suzuki-Trotter product formula. The Suzuki-Trotter formulas improve the error of the Lie-Trotter approximation. For example, the second order decomposition is .. math:: e^{A + B} \approx e^{B/2} e^{A} e^{B/2}. Higher order decom...
if order == 1: return pauli_list elif order == 2: halves = [(op, coeff * time / 2) for op, coeff in pauli_list[:-1]] full = [(pauli_list[-1][0], time * pauli_list[-1][1])] return halves + full + list(reversed(halves)) else: reduction ...
if order == 1: return pauli_list elif order == 2: halves = [(op, coeff * time / 2) for op, coeff in pauli_list[:-1]] full = [(pauli_list[-1][0], time * pauli_list[-1][1])] return halves + full + list(reversed(halves)) else: reduction ...
83
1,157
238
1,395
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2021. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,720
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/linear/cnot_synth.py
75,76
1,144
_lwr_cnot_synth
107,144
76,144
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
circuit = [] num_qubits = state.shape[0] cutoff = 1 # Iterate over column sections for sec in range(1, int(np.floor(num_qubits / section_size) + 1)): # Remove duplicate sub-rows in section sec patt = {} for row in range((sec - 1) * section_size, num_qubits): sub_...
""" This function is a helper function of the algorithm for optimal synthesis of linear reversible circuits (the Patel–Markov–Hayes algorithm). It works like gaussian elimination, except that it works a lot faster, and requires fewer steps (and therefore fewer CNOTs). It takes the matrix "state" and...
182
1,312
525
1,837
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2019. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,721
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/linear/linear_circuits_utils.py
45,46
1,129
optimize_cx_4_options
62,106
46,106
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
if not check_invertible_binary_matrix(mat): raise QiskitError("The matrix is not invertible.") qc = function(mat) best_qc = qc best_depth = qc.depth() best_count = qc.count_ops()["cx"] for i in range(1, 4): mat_cpy = copy.deepcopy(mat) # i=1 inverse, i=2 transpose, i=3 ...
"""Get the best implementation of a circuit implementing a binary invertible matrix M, by considering all four options: M,M^(-1),M^T,M^(-1)^T. Optimizing either the CX count or the depth. Args: function: the synthesis function. mat: a binary invertible matrix. optimize_count: Tr...
169
945
552
1,497
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,723
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/linear/linear_matrix_utils.py
173,174
1,176
_col_op
174,176
174,176
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# Perform COL operation on a matrix mat mat[:, ctrl] = mat[:, trgt] ^ mat[:, ctrl]
# Perform COL operation on a matrix mat mat[:, ctrl] = mat[:, trgt] ^ mat[:, ctrl]
16
1,703
35
1,738
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
# This code is part of Qiskit. # # (C) Copyright IBM 2017, 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivat...
30,727
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/permutation/permutation_full.py
27,28
1,103
synth_permutation_basic
47,60
28,60
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This is the very original Qiskit algorithm for synthesizing permutations. num_qubits = len(pattern) qc = QuantumCircuit(num_qubits) swaps = _get_ordered_swap(pattern) for swap in swaps: qc.swap(swap[0], swap[1]) return qc
"""Synthesize a permutation circuit for a fully-connected architecture using sorting. More precisely, if the input permutation is a cycle of length ``m``, then this creates a quantum circuit with ``m-1`` SWAPs (and of depth ``m-1``); if the input permutation consists of several disjoint cycles, th...
28
1,126
106
1,232
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,728
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/permutation/permutation_lnn.py
21,22
1,75
synth_permutation_depth_lnn_kms
46,64
22,64
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# In Qiskit, the permutation pattern [2, 4, 3, 0, 1] means that # the permutation that maps qubit 2 to position 0, 4 to 1, 3 to 2, 0 to 3, and 1 to 4. # In the permutation synthesis code below the notation is opposite: # [2, 4, 3, 0, 1] means that 0 maps to 2, 1 to 3, 2 to 3, 3 to 0, and 4 to 1. # ...
"""Synthesize a permutation circuit for a linear nearest-neighbor architecture using the Kutin, Moulton, Smithline method. This is the permutation synthesis algorithm from [1], section 6. It synthesizes any permutation of n qubits over linear nearest-neighbor architecture using SWAP gates with dept...
106
772
263
1,035
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
# This code is part of Qiskit. # # (C) Copyright IBM 2022. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wo...
30,729
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/synthesis/permutation/permutation_reverse_lnn.py
19,20
1,91
_append_cx_stage1
21,28
20,28
# This code is part of Qiskit. # # (C) Copyright IBM 2024 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wor...
# This code is part of Qiskit. # # (C) Copyright IBM 2024 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wor...
for i in range(n // 2): qc.cx(2 * i, 2 * i + 1) for i in range((n + 1) // 2 - 1): qc.cx(2 * i + 2, 2 * i + 1) return qc
"""A single layer of CX gates.""" for i in range(n // 2): qc.cx(2 * i, 2 * i + 1) for i in range((n + 1) // 2 - 1): qc.cx(2 * i + 2, 2 * i + 1) return qc
36
1,019
84
1,103
# This code is part of Qiskit. # # (C) Copyright IBM 2024 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wor...
# This code is part of Qiskit. # # (C) Copyright IBM 2024 # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative wor...