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,879
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/utils/barrier_before_final_measurements.py
34,35
22,96
run
BarrierBeforeFinalMeasurements
36,96
35,96
class BarrierBeforeFinalMeasurements(TransformationPass): """Add a barrier before final measurements. This pass adds a barrier before the set of final measurements. Measurements are considered final if they are followed by no other operations (aside from other measurements or barriers.) """ de...
class BarrierBeforeFinalMeasurements(TransformationPass): """Add a barrier before final measurements. This pass adds a barrier before the set of final measurements. Measurements are considered final if they are followed by no other operations (aside from other measurements or barriers.) """ de...
# Collect DAG nodes which are followed only by barriers or other measures. final_op_types = ["measure", "barrier"] final_ops = [] for candidate_node in dag.named_nodes(*final_op_types): is_final_op = True for _, child_successors in dag.bfs_successors(candidate_no...
"""Run the BarrierBeforeFinalMeasurements pass on `dag`.""" # Collect DAG nodes which are followed only by barriers or other measures. final_op_types = ["measure", "barrier"] final_ops = [] for candidate_node in dag.named_nodes(*final_op_types): is_final_op = True ...
200
134
685
819
# 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,880
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/utils/check_gate_direction.py
57,58
20,88
_target_visit
CheckGateDirection
58,73
58,73
class CheckGateDirection(AnalysisPass): """Check if the two-qubit gates follow the right direction with respect to the coupling map. """ def __init__(self, coupling_map, target=None): """CheckGateDirection initializer. Args: coupling_map (CouplingMap): Directed graph repres...
class CheckGateDirection(AnalysisPass): """Check if the two-qubit gates follow the right direction with respect to the coupling map. """ def __init__(self, coupling_map, target=None): """CheckGateDirection initializer. Args: coupling_map (CouplingMap): Directed graph repres...
# Don't include directives to avoid things like barrier, which are assumed always supported. for node in dag.op_nodes(include_directives=False): if isinstance(node.op, ControlFlowOp): for block in node.op.blocks: inner_wire_map = { ...
# Don't include directives to avoid things like barrier, which are assumed always supported. for node in dag.op_nodes(include_directives=False): if isinstance(node.op, ControlFlowOp): for block in node.op.blocks: inner_wire_map = { ...
58
595
218
813
# 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,881
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/utils/check_map.py
59,60
21,95
run
CheckMap
68,74
60,74
class CheckMap(AnalysisPass): """Check if a DAG circuit is already mapped to a coupling map. Check if a DAGCircuit is mapped to ``coupling_map`` by checking that all 2-qubit interactions are laid out to be on adjacent qubits in the global coupling map of the device, setting the property set field (eith...
class CheckMap(AnalysisPass): """Check if a DAG circuit is already mapped to a coupling map. Check if a DAGCircuit is mapped to ``coupling_map`` by checking that all 2-qubit interactions are laid out to be on adjacent qubits in the global coupling map of the device, setting the property set field (eith...
if not self.qargs: self.property_set[self.property_set_field] = True return wire_map = {bit: index for index, bit in enumerate(dag.qubits)} self.property_set[self.property_set_field] = self._recurse(dag, wire_map)
"""Run the CheckMap pass on `dag`. If `dag` is mapped to `coupling_map`, the property `is_swap_mapped` is set to True (or to False otherwise). Args: dag (DAGCircuit): DAG to map. """ if not self.qargs: self.property_set[self.property_set_field] =...
20
821
89
910
# 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,882
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/utils/contains_instruction.py
41,42
18,46
run
ContainsInstruction
43,46
42,46
class ContainsInstruction(AnalysisPass): """An analysis pass to detect if the DAG contains a specific instruction. This pass takes in a single instruction name for example ``'delay'`` and will set the property set ``contains_delay`` to ``True`` if the DAG contains that instruction and ``False`` if it d...
class ContainsInstruction(AnalysisPass): """An analysis pass to detect if the DAG contains a specific instruction. This pass takes in a single instruction name for example ``'delay'`` and will set the property set ``contains_delay`` to ``True`` if the DAG contains that instruction and ``False`` if it d...
names = dag.count_ops(recurse=self._recurse) for name in self._instruction_names: self.property_set[f"contains_{name}"] = name in names
"""Run the ContainsInstruction pass on dag.""" names = dag.count_ops(recurse=self._recurse) for name in self._instruction_names: self.property_set[f"contains_{name}"] = name in names
12
289
55
344
# 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,883
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/utils/control_flow.py
35,36
1,62
trivial_recurse
51,62
36,62
# 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...
@functools.wraps(method) def out(self, dag): def bound_wrapped_method(dag): return out(self, dag) for node in dag.op_nodes(ControlFlowOp): node.op = map_blocks(bound_wrapped_method, node.op) return method(self, dag) return out
"""Decorator that causes :class:`.BasePass.run` to iterate over all control-flow nodes, replacing their operations with a new :class:`.ControlFlowOp` whose blocks have all had :class`.BasePass.run` called on them. This is only suitable for simple run calls that store no state between calls, do not need...
22
607
109
716
# 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,884
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/utils/convert_conditions_to_if_ops.py
35,36
28,90
_run_inner
ConvertConditionsToIfOps
38,87
36,87
class ConvertConditionsToIfOps(TransformationPass): """Convert instructions whose ``condition`` attribute is set to a non-``None`` value into the equivalent single-statement :class:`.IfElseBlock`. This is a simple pass aimed at easing the conversion from the old style of using :meth:`.InstructionSet.c_...
class ConvertConditionsToIfOps(TransformationPass): """Convert instructions whose ``condition`` attribute is set to a non-``None`` value into the equivalent single-statement :class:`.IfElseBlock`. This is a simple pass aimed at easing the conversion from the old style of using :meth:`.InstructionSet.c_...
modified = False for node in dag.op_nodes(): if isinstance(node.op, ControlFlowOp): modified_blocks = False new_dags = [] for block in node.op.blocks: new_dag = circuit_to_dag(block) modified_blocks |= se...
"""Run the pass on one :class:`.DAGCircuit`, mutating it. Returns ``True`` if the circuit was modified and ``False`` if not.""" modified = False for node in dag.op_nodes(): if isinstance(node.op, ControlFlowOp): modified_blocks = False new_dag...
161
191
643
834
# 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,885
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/utils/dag_fixed_point.py
28,29
20,37
run
DAGFixedPoint
30,37
29,37
class DAGFixedPoint(AnalysisPass): """Check if the DAG has reached a fixed point. A dummy analysis pass that checks if the DAG a fixed point (the DAG is not modified anymore). The result is saved in ``property_set['dag_fixed_point']`` as a boolean. """ def run(self, dag): FILL_FUNC_BODY
class DAGFixedPoint(AnalysisPass): """Check if the DAG has reached a fixed point. A dummy analysis pass that checks if the DAG a fixed point (the DAG is not modified anymore). The result is saved in ``property_set['dag_fixed_point']`` as a boolean. """ def run(self, dag): """Run the DA...
if self.property_set["_dag_fixed_point_previous_dag"] is None: self.property_set["dag_fixed_point"] = False else: fixed_point_reached = self.property_set["_dag_fixed_point_previous_dag"] == dag self.property_set["dag_fixed_point"] = fixed_point_reached self.p...
"""Run the DAGFixedPoint pass on `dag`.""" if self.property_set["_dag_fixed_point_previous_dag"] is None: self.property_set["dag_fixed_point"] = False else: fixed_point_reached = self.property_set["_dag_fixed_point_previous_dag"] == dag self.property_set["dag_...
19
114
126
240
# 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,886
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/utils/error.py
48,49
23,70
run
Error
50,70
49,70
class Error(AnalysisPass): """Error pass to be called when an error happens.""" def __init__(self, msg=None, action="raise"): """Error pass. Args: msg (str | Callable[[PropertySet], str]): Error message, if not provided a generic error will be used. This can be eit...
class Error(AnalysisPass): """Error pass to be called when an error happens.""" def __init__(self, msg=None, action="raise"): """Error pass. Args: msg (str | Callable[[PropertySet], str]): Error message, if not provided a generic error will be used. This can be eit...
if self.msg is None: msg = "An error occurred while the pass manager was running." elif isinstance(self.msg, str): prop_names = [ tup[1] for tup in string.Formatter().parse(self.msg) if tup[1] is not None ] properties = {prop_name: self.pro...
"""Run the Error pass on `dag`.""" if self.msg is None: msg = "An error occurred while the pass manager was running." elif isinstance(self.msg, str): prop_names = [ tup[1] for tup in string.Formatter().parse(self.msg) if tup[1] is not None ] ...
74
303
250
553
# 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,887
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/utils/filter_op_nodes.py
59,61
22,66
run
FilterOpNodes
62,66
61,66
class FilterOpNodes(TransformationPass): """Remove all operations that match a filter function This transformation pass is used to remove any operations that matches a the provided filter function. Args: predicate: A given callable that will be passed the :class:`.DAGOpNode` for each...
class FilterOpNodes(TransformationPass): """Remove all operations that match a filter function This transformation pass is used to remove any operations that matches a the provided filter function. Args: predicate: A given callable that will be passed the :class:`.DAGOpNode` for each...
for node in dag.op_nodes(): if not self.predicate(node): dag.remove_op_node(node) return dag
"""Run the RemoveBarriers pass on `dag`.""" for node in dag.op_nodes(): if not self.predicate(node): dag.remove_op_node(node) return dag
10
379
45
424
# 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,888
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/utils/fixed_point.py
37,38
20,49
run
FixedPoint
39,49
38,49
class FixedPoint(AnalysisPass): """Check if a property reached a fixed point. A dummy analysis pass that checks if a property reached a fixed point. The result is saved in ``property_set['<property>_fixed_point']`` as a boolean. """ def __init__(self, property_to_check): """FixedPoint ...
class FixedPoint(AnalysisPass): """Check if a property reached a fixed point. A dummy analysis pass that checks if a property reached a fixed point. The result is saved in ``property_set['<property>_fixed_point']`` as a boolean. """ def __init__(self, property_to_check): """FixedPoint ...
current_value = self.property_set[self._property] fixed_point_previous_property = "_fixed_point_previous_%s" % self._property if self.property_set[fixed_point_previous_property] is None: self.property_set["%s_fixed_point" % self._property] = False else: fixed_poi...
"""Run the FixedPoint pass on `dag`.""" current_value = self.property_set[self._property] fixed_point_previous_property = "_fixed_point_previous_%s" % self._property if self.property_set[fixed_point_previous_property] is None: self.property_set["%s_fixed_point" % self._prope...
31
174
176
350
# 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,891
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/utils/gates_basis.py
39,40
20,76
run
GatesInBasis
41,76
40,76
class GatesInBasis(AnalysisPass): """Check if all gates in a DAG are in a given set of gates""" def __init__(self, basis_gates=None, target=None): """Initialize the GatesInBasis pass. Args: basis_gates (list): The list of strings representing the set of basis gates. tar...
class GatesInBasis(AnalysisPass): """Check if all gates in a DAG are in a given set of gates""" def __init__(self, basis_gates=None, target=None): """Initialize the GatesInBasis pass. Args: basis_gates (list): The list of strings representing the set of basis gates. tar...
if self._basis_gates is None and self._target is None: self.property_set["all_gates_in_basis"] = True return gates_out_of_basis = False if self._target is not None: def _visit_target(dag, wire_map): for gate in dag.op_nodes(): ...
"""Run the GatesInBasis pass on `dag`.""" if self._basis_gates is None and self._target is None: self.property_set["all_gates_in_basis"] = True return gates_out_of_basis = False if self._target is not None: def _visit_target(dag, wire_map): ...
131
242
460
702
# 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,892
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/utils/merge_adjacent_barriers.py
81,83
19,163
_collect_potential_merges
MergeAdjacentBarriers
89,163
83,163
class MergeAdjacentBarriers(TransformationPass): """Return a circuit with any adjacent barriers merged together. Only barriers which can be merged without affecting the barrier structure of the DAG will be merged. Not all redundant barriers will necessarily be merged, only adjacent barriers are me...
class MergeAdjacentBarriers(TransformationPass): """Return a circuit with any adjacent barriers merged together. Only barriers which can be merged without affecting the barrier structure of the DAG will be merged. Not all redundant barriers will necessarily be merged, only adjacent barriers are me...
# if only got 1 or 0 barriers then can't merge if len(barriers) < 2: return None # mapping from the node that will be the main barrier to the # barrier object that gets built up node_to_barrier_qubits = {} # Start from the first barrier current_barri...
"""Return the potential merges. Returns a dict of DAGOpNode: (Barrier, [DAGOpNode]) objects, where the barrier needs to be inserted where the corresponding index DAGOpNode appears in the main DAG, in replacement of the listed DAGOpNodes. """ # if only got 1 or 0 barriers...
251
730
930
1,660
# 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,893
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/utils/minimum_point.py
75,76
24,112
run
MinimumPoint
77,112
76,112
class MinimumPoint(TransformationPass): """Check if the DAG has reached a relative semi-stable point over previous runs This pass is similar to the :class:`~.FixedPoint` transpiler pass and is intended primarily to be used to set a loop break condition in the property set. However, unlike the :class:`~...
class MinimumPoint(TransformationPass): """Check if the DAG has reached a relative semi-stable point over previous runs This pass is similar to the :class:`~.FixedPoint` transpiler pass and is intended primarily to be used to set a loop break condition in the property set. However, unlike the :class:`~...
score = tuple(self.property_set[x] for x in self.property_set_list) state = self.property_set[self.backtrack_name] # The pass starts at None and the first iteration doesn't set a real # score so the overall loop is treated as a do-while to ensure we have # at least 2 iterations....
"""Run the MinimumPoint pass on `dag`.""" score = tuple(self.property_set[x] for x in self.property_set_list) state = self.property_set[self.backtrack_name] # The pass starts at None and the first iteration doesn't set a real # score so the overall loop is treated as a do-while ...
202
688
458
1,146
# 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 wor...
# 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 wor...
30,894
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/utils/remove_barriers.py
43,45
20,50
run
RemoveBarriers
46,50
45,50
class RemoveBarriers(TransformationPass): """Return a circuit with any barrier removed. This transformation is not semantics preserving. Example: .. plot:: :include-source: from qiskit import QuantumCircuit from qiskit.transpiler.passes import RemoveBarriers ...
class RemoveBarriers(TransformationPass): """Return a circuit with any barrier removed. This transformation is not semantics preserving. Example: .. plot:: :include-source: from qiskit import QuantumCircuit from qiskit.transpiler.passes import RemoveBarriers ...
dag.remove_all_ops_named("barrier") return dag
"""Run the RemoveBarriers pass on `dag`.""" dag.remove_all_ops_named("barrier") return dag
3
198
27
225
# 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,895
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/utils/remove_final_measurements.py
35,36
19,115
_calc_final_ops
RemoveFinalMeasurements
36,66
36,66
class RemoveFinalMeasurements(TransformationPass): """Remove final measurements and barriers at the end of a circuit. This pass removes final barriers and final measurements, as well as all unused classical registers and bits they are connected to. Measurements and barriers are considered final if they...
class RemoveFinalMeasurements(TransformationPass): """Remove final measurements and barriers at the end of a circuit. This pass removes final barriers and final measurements, as well as all unused classical registers and bits they are connected to. Measurements and barriers are considered final if they...
final_op_types = {"measure", "barrier"} final_ops = [] to_visit = [next(dag.predecessors(dag.output_map[qubit])) for qubit in dag.qubits] barrier_encounters_remaining = {} while to_visit: node = to_visit.pop() if not isinstance(node, DAGOpNode): ...
final_op_types = {"measure", "barrier"} final_ops = [] to_visit = [next(dag.predecessors(dag.output_map[qubit])) for qubit in dag.qubits] barrier_encounters_remaining = {} while to_visit: node = to_visit.pop() if not isinstance(node, DAGOpNode): ...
123
730
372
1,102
# 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,896
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/utils/unroll_forloops.py
71,72
1,82
_body_contains_continue_or_break
73,82
72,82
# 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...
for inst in circuit.data: operation = inst.operation if isinstance(operation, (ContinueLoopOp, BreakLoopOp)): return True if isinstance(operation, IfElseOp): for block in operation.params: if _body_contains_continue_or_break(block): ...
"""Checks if a circuit contains ``continue``s or ``break``s. Conditional bodies are inspected.""" for inst in circuit.data: operation = inst.operation if isinstance(operation, (ContinueLoopOp, BreakLoopOp)): return True if isinstance(operation, IfElseOp): for bloc...
26
846
94
940
# 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,897
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/passes/utils/unroll_forloops.py
39,41
21,71
run
UnrollForLoops
49,71
41,71
class UnrollForLoops(TransformationPass): """``UnrollForLoops`` transpilation pass unrolls for-loops when possible.""" def __init__(self, max_target_depth=-1): """Things like ``for x in {0, 3, 4} {rx(x) qr[1];}`` will turn into ``rx(0) qr[1]; rx(3) qr[1]; rx(4) qr[1];``. .. note:: ...
class UnrollForLoops(TransformationPass): """``UnrollForLoops`` transpilation pass unrolls for-loops when possible.""" def __init__(self, max_target_depth=-1): """Things like ``for x in {0, 3, 4} {rx(x) qr[1];}`` will turn into ``rx(0) qr[1]; rx(3) qr[1]; rx(4) qr[1];``. .. note:: ...
for forloop_op in dag.op_nodes(ForLoopOp): (indexset, loop_param, body) = forloop_op.op.params # skip unrolling if it results in bigger than max_target_depth if 0 < self.max_target_depth < len(indexset) * body.depth(): continue # skip unroll when...
"""Run the UnrollForLoops pass on ``dag``. Args: dag (DAGCircuit): the directed acyclic graph to run on. Returns: DAGCircuit: Transformed DAG. """ for forloop_op in dag.op_nodes(ForLoopOp): (indexset, loop_param, body) = forloop_op.op.params ...
63
335
265
600
# 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,899
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/preset_passmanagers/builtin_plugins.py
632,633
629,646
pass_manager
AlapSchedulingPassManager
634,646
633,646
class AlapSchedulingPassManager(PassManagerStagePlugin): """Plugin class for alap scheduling stage.""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: FILL_FUNC_BODY
class AlapSchedulingPassManager(PassManagerStagePlugin): """Plugin class for alap scheduling stage.""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: """Build scheduling stage PassManager""" FILL_FUNC_BODY
instruction_durations = pass_manager_config.instruction_durations scheduling_method = pass_manager_config.scheduling_method timing_constraints = pass_manager_config.timing_constraints inst_map = pass_manager_config.inst_map target = pass_manager_config.target return com...
"""Build scheduling stage PassManager""" instruction_durations = pass_manager_config.instruction_durations scheduling_method = pass_manager_config.scheduling_method timing_constraints = pass_manager_config.timing_constraints inst_map = pass_manager_config.inst_map target...
23
72
131
203
# 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,900
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/preset_passmanagers/builtin_plugins.py
649,650
646,663
pass_manager
AsapSchedulingPassManager
651,663
650,663
class AsapSchedulingPassManager(PassManagerStagePlugin): """Plugin class for alap scheduling stage.""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: FILL_FUNC_BODY
class AsapSchedulingPassManager(PassManagerStagePlugin): """Plugin class for alap scheduling stage.""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: """Build scheduling stage PassManager""" FILL_FUNC_BODY
instruction_durations = pass_manager_config.instruction_durations scheduling_method = pass_manager_config.scheduling_method timing_constraints = pass_manager_config.timing_constraints inst_map = pass_manager_config.inst_map target = pass_manager_config.target return com...
"""Build scheduling stage PassManager""" instruction_durations = pass_manager_config.instruction_durations scheduling_method = pass_manager_config.scheduling_method timing_constraints = pass_manager_config.timing_constraints inst_map = pass_manager_config.inst_map target...
23
72
131
203
# 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,901
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/preset_passmanagers/builtin_plugins.py
199,200
196,260
pass_manager
BasicSwapPassManager
201,260
200,260
class BasicSwapPassManager(PassManagerStagePlugin): """Plugin class for routing stage with :class:`~.BasicSwap`""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: FILL_FUNC_BODY
class BasicSwapPassManager(PassManagerStagePlugin): """Plugin class for routing stage with :class:`~.BasicSwap`""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: """Build routing stage PassManager.""" FILL_FUNC_BODY
seed_transpiler = pass_manager_config.seed_transpiler target = pass_manager_config.target coupling_map = pass_manager_config.coupling_map backend_properties = pass_manager_config.backend_properties if target is None: routing_pass = BasicSwap(coupling_map) else...
"""Build routing stage PassManager.""" seed_transpiler = pass_manager_config.seed_transpiler target = pass_manager_config.target coupling_map = pass_manager_config.coupling_map backend_properties = pass_manager_config.backend_properties if target is None: rout...
95
80
692
772
# 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,902
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/preset_passmanagers/builtin_plugins.py
165,166
162,179
pass_manager
BasisTranslatorPassManager
166,179
166,179
class BasisTranslatorPassManager(PassManagerStagePlugin): """Plugin class for translation stage with :class:`~.BasisTranslator`""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: FILL_FUNC_BODY
class BasisTranslatorPassManager(PassManagerStagePlugin): """Plugin class for translation stage with :class:`~.BasisTranslator`""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: FILL_FUNC_BODY
return common.generate_translation_passmanager( pass_manager_config.target, basis_gates=pass_manager_config.basis_gates, method="translator", approximation_degree=pass_manager_config.approximation_degree, coupling_map=pass_manager_config.coupling_map, ...
return common.generate_translation_passmanager( pass_manager_config.target, basis_gates=pass_manager_config.basis_gates, method="translator", approximation_degree=pass_manager_config.approximation_degree, coupling_map=pass_manager_config.coupling_map, ...
12
75
192
267
# 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,903
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/preset_passmanagers/builtin_plugins.py
71,72
68,162
pass_manager
DefaultInitPassManager
72,162
72,162
class DefaultInitPassManager(PassManagerStagePlugin): """Plugin class for default init stage.""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: FILL_FUNC_BODY
class DefaultInitPassManager(PassManagerStagePlugin): """Plugin class for default init stage.""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: FILL_FUNC_BODY
if optimization_level == 0: init = None if ( pass_manager_config.initial_layout or pass_manager_config.coupling_map or ( pass_manager_config.target is not None and pass_manager_config.target.build_cou...
if optimization_level == 0: init = None if ( pass_manager_config.initial_layout or pass_manager_config.coupling_map or ( pass_manager_config.target is not None and pass_manager_config.target.build_cou...
138
60
911
971
# 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,904
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/preset_passmanagers/builtin_plugins.py
683,684
680,832
pass_manager
DefaultLayoutPassManager
684,832
684,832
class DefaultLayoutPassManager(PassManagerStagePlugin): """Plugin class for default layout stage.""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: FILL_FUNC_BODY
class DefaultLayoutPassManager(PassManagerStagePlugin): """Plugin class for default layout stage.""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: FILL_FUNC_BODY
_given_layout = SetLayout(pass_manager_config.initial_layout) def _choose_layout_condition(property_set): return not property_set["layout"] def _layout_not_perfect(property_set): """Return ``True`` if the first attempt at layout has been checked and found to be ...
_given_layout = SetLayout(pass_manager_config.initial_layout) def _choose_layout_condition(property_set): return not property_set["layout"] def _layout_not_perfect(property_set): """Return ``True`` if the first attempt at layout has been checked and found to be ...
359
60
1,818
1,878
# 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,905
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/preset_passmanagers/builtin_plugins.py
666,667
663,680
pass_manager
DefaultSchedulingPassManager
668,680
667,680
class DefaultSchedulingPassManager(PassManagerStagePlugin): """Plugin class for alap scheduling stage.""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: FILL_FUNC_BODY
class DefaultSchedulingPassManager(PassManagerStagePlugin): """Plugin class for alap scheduling stage.""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: """Build scheduling stage PassManager""" FILL_FUNC_BODY
instruction_durations = pass_manager_config.instruction_durations scheduling_method = None timing_constraints = pass_manager_config.timing_constraints or TimingConstraints() inst_map = pass_manager_config.inst_map target = pass_manager_config.target return common.genera...
"""Build scheduling stage PassManager""" instruction_durations = pass_manager_config.instruction_durations scheduling_method = None timing_constraints = pass_manager_config.timing_constraints or TimingConstraints() inst_map = pass_manager_config.inst_map target = pass_ma...
25
71
128
199
# 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,906
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/preset_passmanagers/builtin_plugins.py
858,859
855,885
pass_manager
DenseLayoutPassManager
859,885
859,885
class DenseLayoutPassManager(PassManagerStagePlugin): """Plugin class for dense layout stage.""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: FILL_FUNC_BODY
class DenseLayoutPassManager(PassManagerStagePlugin): """Plugin class for dense layout stage.""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: FILL_FUNC_BODY
_given_layout = SetLayout(pass_manager_config.initial_layout) def _choose_layout_condition(property_set): return not property_set["layout"] if pass_manager_config.target is None: coupling_map = pass_manager_config.coupling_map else: coupling_map = pa...
_given_layout = SetLayout(pass_manager_config.initial_layout) def _choose_layout_condition(property_set): return not property_set["layout"] if pass_manager_config.target is None: coupling_map = pass_manager_config.coupling_map else: coupling_map = pa...
38
61
244
305
# 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,907
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/preset_passmanagers/builtin_plugins.py
319,320
316,382
pass_manager
LookaheadSwapPassManager
321,382
320,382
class LookaheadSwapPassManager(PassManagerStagePlugin): """Plugin class for routing stage with :class:`~.LookaheadSwap`""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: FILL_FUNC_BODY
class LookaheadSwapPassManager(PassManagerStagePlugin): """Plugin class for routing stage with :class:`~.LookaheadSwap`""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: """Build routing stage PassManager.""" FILL_FUNC_BODY
seed_transpiler = pass_manager_config.seed_transpiler target = pass_manager_config.target coupling_map = pass_manager_config.coupling_map coupling_map_routing = target if coupling_map_routing is None: coupling_map_routing = coupling_map backend_properties = pa...
"""Build routing stage PassManager.""" seed_transpiler = pass_manager_config.seed_transpiler target = pass_manager_config.target coupling_map = pass_manager_config.coupling_map coupling_map_routing = target if coupling_map_routing is None: coupling_map_routing...
114
84
817
901
# 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,908
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/preset_passmanagers/builtin_plugins.py
471,472
468,490
pass_manager
NoneRoutingPassManager
473,490
472,490
class NoneRoutingPassManager(PassManagerStagePlugin): """Plugin class for routing stage with error on routing.""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: FILL_FUNC_BODY
class NoneRoutingPassManager(PassManagerStagePlugin): """Plugin class for routing stage with error on routing.""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: """Build routing stage PassManager.""" FILL_FUNC_BODY
seed_transpiler = pass_manager_config.seed_transpiler target = pass_manager_config.target coupling_map = pass_manager_config.coupling_map routing_pass = Error( msg="No routing method selected, but circuit is not routed to device. " "CheckMap Error: {check_map_msg}...
"""Build routing stage PassManager.""" seed_transpiler = pass_manager_config.seed_transpiler target = pass_manager_config.target coupling_map = pass_manager_config.coupling_map routing_pass = Error( msg="No routing method selected, but circuit is not routed to device....
37
73
183
256
# 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,909
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/preset_passmanagers/builtin_plugins.py
493,494
490,629
pass_manager
OptimizationPassManager
495,629
494,629
class OptimizationPassManager(PassManagerStagePlugin): """Plugin class for optimization stage""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: FILL_FUNC_BODY
class OptimizationPassManager(PassManagerStagePlugin): """Plugin class for optimization stage""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: """Build pass manager for optimization stage.""" FILL_FUNC_BODY
# Obtain the translation method required for this pass to work translation_method = pass_manager_config.translation_method or "translator" optimization = PassManager() if optimization_level != 0: plugin_manager = PassManagerStagePluginManager() _depth_check = [Dep...
"""Build pass manager for optimization stage.""" # Obtain the translation method required for this pass to work translation_method = pass_manager_config.translation_method or "translator" optimization = PassManager() if optimization_level != 0: plugin_manager = PassMa...
263
69
1,536
1,605
# 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,910
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/preset_passmanagers/builtin_plugins.py
888,889
885,960
pass_manager
SabreLayoutPassManager
889,960
889,960
class SabreLayoutPassManager(PassManagerStagePlugin): """Plugin class for sabre layout stage.""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: FILL_FUNC_BODY
class SabreLayoutPassManager(PassManagerStagePlugin): """Plugin class for sabre layout stage.""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: FILL_FUNC_BODY
_given_layout = SetLayout(pass_manager_config.initial_layout) def _choose_layout_condition(property_set): return not property_set["layout"] def _swap_mapped(property_set): return property_set["final_layout"] is None if pass_manager_config.target is None: ...
_given_layout = SetLayout(pass_manager_config.initial_layout) def _choose_layout_condition(property_set): return not property_set["layout"] def _swap_mapped(property_set): return property_set["final_layout"] is None if pass_manager_config.target is None: ...
137
62
805
867
# 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,911
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/preset_passmanagers/builtin_plugins.py
385,386
382,468
pass_manager
SabreSwapPassManager
387,468
386,468
class SabreSwapPassManager(PassManagerStagePlugin): """Plugin class for routing stage with :class:`~.SabreSwap`""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: FILL_FUNC_BODY
class SabreSwapPassManager(PassManagerStagePlugin): """Plugin class for routing stage with :class:`~.SabreSwap`""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: """Build routing stage PassManager.""" FILL_FUNC_BODY
seed_transpiler = pass_manager_config.seed_transpiler target = pass_manager_config.target coupling_map = pass_manager_config.coupling_map coupling_map_routing = target if coupling_map_routing is None: coupling_map_routing = coupling_map backend_properties = pa...
"""Build routing stage PassManager.""" seed_transpiler = pass_manager_config.seed_transpiler target = pass_manager_config.target coupling_map = pass_manager_config.coupling_map coupling_map_routing = target if coupling_map_routing is None: coupling_map_routing...
126
83
906
989
# 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,912
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/preset_passmanagers/builtin_plugins.py
263,264
260,316
pass_manager
StochasticSwapPassManager
265,316
264,316
class StochasticSwapPassManager(PassManagerStagePlugin): """Plugin class for routing stage with :class:`~.StochasticSwap`""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: FILL_FUNC_BODY
class StochasticSwapPassManager(PassManagerStagePlugin): """Plugin class for routing stage with :class:`~.StochasticSwap`""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: """Build routing stage PassManager.""" FILL_FUNC_BODY
seed_transpiler = pass_manager_config.seed_transpiler target = pass_manager_config.target coupling_map = pass_manager_config.coupling_map coupling_map_routing = target if coupling_map_routing is None: coupling_map_routing = coupling_map backend_properties = pa...
"""Build routing stage PassManager.""" seed_transpiler = pass_manager_config.seed_transpiler target = pass_manager_config.target coupling_map = pass_manager_config.coupling_map coupling_map_routing = target if coupling_map_routing is None: coupling_map_routing...
95
85
641
726
# 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,913
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/preset_passmanagers/builtin_plugins.py
838,839
832,855
_choose_layout_condition
TrivialLayoutPassManager
839,841
839,841
class TrivialLayoutPassManager(PassManagerStagePlugin): """Plugin class for trivial layout stage.""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: _given_layout = SetLayout(pass_manager_config.initial_layout) def _choose_layout_condition(property_set): FI...
class TrivialLayoutPassManager(PassManagerStagePlugin): """Plugin class for trivial layout stage.""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: _given_layout = SetLayout(pass_manager_config.initial_layout) def _choose_layout_condition(property_set): FI...
return not property_set["layout"]
return not property_set["layout"]
3
217
13
230
# 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,914
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/preset_passmanagers/builtin_plugins.py
182,183
179,196
pass_manager
UnitarySynthesisPassManager
183,196
183,196
class UnitarySynthesisPassManager(PassManagerStagePlugin): """Plugin class for translation stage with :class:`~.BasisTranslator`""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: FILL_FUNC_BODY
class UnitarySynthesisPassManager(PassManagerStagePlugin): """Plugin class for translation stage with :class:`~.BasisTranslator`""" def pass_manager(self, pass_manager_config, optimization_level=None) -> PassManager: FILL_FUNC_BODY
return common.generate_translation_passmanager( pass_manager_config.target, basis_gates=pass_manager_config.basis_gates, method="synthesis", approximation_degree=pass_manager_config.approximation_degree, coupling_map=pass_manager_config.coupling_map, ...
return common.generate_translation_passmanager( pass_manager_config.target, basis_gates=pass_manager_config.basis_gates, method="synthesis", approximation_degree=pass_manager_config.approximation_degree, coupling_map=pass_manager_config.coupling_map, ...
12
75
192
267
# 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,916
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/preset_passmanagers/common.py
96,97
83,111
message
_InvalidControlFlowForBackend
98,106
97,106
class _InvalidControlFlowForBackend: # Explicitly stateful closure to allow pickling. def __init__(self, basis_gates=(), target=None): if target is not None: self.unsupported = [op for op in CONTROL_FLOW_OP_NAMES if op not in target] elif basis_gates is not None: basis_g...
class _InvalidControlFlowForBackend: # Explicitly stateful closure to allow pickling. def __init__(self, basis_gates=(), target=None): if target is not None: self.unsupported = [op for op in CONTROL_FLOW_OP_NAMES if op not in target] elif basis_gates is not None: basis_g...
fails = [x for x in self.unsupported if property_set[f"contains_{x}"]] if len(fails) == 1: return f"The control-flow construct '{fails[0]}' is not supported by the backend." return ( f"The control-flow constructs [{', '.join(repr(op) for op in fails)}]" " are ...
"""Create an error message for the given property set.""" fails = [x for x in self.unsupported if property_set[f"contains_{x}"]] if len(fails) == 1: return f"The control-flow construct '{fails[0]}' is not supported by the backend." return ( f"The control-flow cons...
43
251
115
366
# 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,917
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/preset_passmanagers/level0.py
26,27
1,114
level_0_pass_manager
45,114
27,114
# 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...
plugin_manager = PassManagerStagePluginManager() basis_gates = pass_manager_config.basis_gates coupling_map = pass_manager_config.coupling_map initial_layout = pass_manager_config.initial_layout init_method = pass_manager_config.init_method or "default" layout_method = pass_manager_config.layout...
"""Level 0 pass manager: no explicit optimization other than mapping to backend. This pass manager applies the user-given initial layout. If none is given, a trivial layout consisting of mapping the i-th virtual qubit to the i-th physical qubit is used. Any unused physical qubit is allocated as ancilla...
162
464
800
1,264
# 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,918
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/preset_passmanagers/level1.py
26,27
1,121
level_1_pass_manager
47,121
27,121
# 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...
plugin_manager = PassManagerStagePluginManager() basis_gates = pass_manager_config.basis_gates coupling_map = pass_manager_config.coupling_map initial_layout = pass_manager_config.initial_layout init_method = pass_manager_config.init_method or "default" # Unlike other presets, the layout and rou...
"""Level 1 pass manager: light optimization by simple adjacent gate collapsing. This pass manager applies the user-given initial layout. If none is given, and a trivial layout (i-th virtual -> i-th physical) makes the circuit fit the coupling map, that is used. Otherwise, the circuit is mapped to t...
188
524
873
1,397
# 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,919
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/preset_passmanagers/level2.py
27,28
1,120
level_2_pass_manager
50,120
28,120
# 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...
plugin_manager = PassManagerStagePluginManager() basis_gates = pass_manager_config.basis_gates coupling_map = pass_manager_config.coupling_map initial_layout = pass_manager_config.initial_layout init_method = pass_manager_config.init_method or "default" layout_method = pass_manager_config.layout...
"""Level 2 pass manager: medium optimization by initial layout selection and gate cancellation using commutativity rules. This pass manager applies the user-given initial layout. If none is given, a search for a perfect layout (i.e. one that satisfies all 2-qubit interactions) is conducted. If no s...
162
540
832
1,372
# 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,920
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/preset_passmanagers/level3.py
27,28
1,120
level_3_pass_manager
50,120
28,120
# 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...
plugin_manager = PassManagerStagePluginManager() basis_gates = pass_manager_config.basis_gates coupling_map = pass_manager_config.coupling_map initial_layout = pass_manager_config.initial_layout init_method = pass_manager_config.init_method or "default" layout_method = pass_manager_config.layout...
"""Level 3 pass manager: heavy optimization by noise adaptive qubit mapping and gate cancellation using commutativity rules and unitary synthesis. This pass manager applies the user-given initial layout. If none is given, a search for a perfect layout (i.e. one that satisfies all 2-qubit interactions) ...
165
568
847
1,415
# 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,922
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/preset_passmanagers/plugin.py
234,241
210,283
get_passmanager_stage
PassManagerStagePluginManager
242,269
241,269
class PassManagerStagePluginManager: """Manager class for preset pass manager stage plugins.""" def __init__(self): super().__init__() self.init_plugins = stevedore.ExtensionManager( "qiskit.transpiler.init", invoke_on_load=True, propagate_map_exceptions=True ) self....
class PassManagerStagePluginManager: """Manager class for preset pass manager stage plugins.""" def __init__(self): super().__init__() self.init_plugins = stevedore.ExtensionManager( "qiskit.transpiler.init", invoke_on_load=True, propagate_map_exceptions=True ) self....
if stage_name == "init": return self._build_pm( self.init_plugins, stage_name, plugin_name, pm_config, optimization_level ) elif stage_name == "layout": return self._build_pm( self.layout_plugins, stage_name, plugin_name, pm_config, opt...
"""Get a stage""" if stage_name == "init": return self._build_pm( self.init_plugins, stage_name, plugin_name, pm_config, optimization_level ) elif stage_name == "layout": return self._build_pm( self.layout_plugins, stage_name, p...
78
557
328
885
# 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,924
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/transpiler/target.py
91,93
58,139
calibration
InstructionProperties
119,123
93,123
class InstructionProperties: """A representation of the properties of a gate implementation. This class provides the optional properties that a backend can provide about an instruction. These represent the set that the transpiler can currently work with if present. However, if your backend provides add...
class InstructionProperties: """A representation of the properties of a gate implementation. This class provides the optional properties that a backend can provide about an instruction. These represent the set that the transpiler can currently work with if present. However, if your backend provides add...
if self._calibration is None: return None return self._calibration.get_schedule()
"""The pulse representation of the instruction. .. note:: This attribute always returns a Qiskit pulse program, but it is internally wrapped by the :class:`.CalibrationEntry` to manage unbound parameters and to uniformly handle different data representation, ...
8
797
34
831
# This code is part of Qiskit. # # (C) Copyright IBM 2021, 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 2021, 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,927
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/user_config.py
54,55
24,159
read_config_file
UserConfig
56,159
55,159
class UserConfig: """Class representing a user config file The config file format should look like: [default] circuit_drawer = mpl circuit_mpl_style = default circuit_mpl_style_path = ~/.qiskit:<default location> circuit_reverse_bits = True transpile_optimization_level = 1 parallel...
class UserConfig: """Class representing a user config file The config file format should look like: [default] circuit_drawer = mpl circuit_mpl_style = default circuit_mpl_style_path = ~/.qiskit:<default location> circuit_reverse_bits = True transpile_optimization_level = 1 parallel...
if not os.path.isfile(self.filename): return self.config_parser.read(self.filename) if "default" in self.config_parser.sections(): # Parse circuit_drawer circuit_drawer = self.config_parser.get("default", "circuit_drawer", fallback=None) if circuit...
"""Read config file and parse the contents into the settings attr.""" if not os.path.isfile(self.filename): return self.config_parser.read(self.filename) if "default" in self.config_parser.sections(): # Parse circuit_drawer circuit_drawer = self.config...
323
258
1,314
1,572
# 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,928
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/utils/classtools.py
120,121
1,147
wrap_method
141,147
121,147
# 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...
# The best time to apply decorators to methods is before they are bound (e.g. by using function # decorators during the class definition), but if we're making a class decorator, we can't do # that. We need the actual definition of the method, so we have to dodge the normal output of # `type.__getattrib...
"""Wrap the functionality the instance- or class method ``cls.name`` with additional behaviour ``before`` and ``after``. This mutates ``cls``, replacing the attribute ``name`` with the new functionality. This is useful when creating class decorators. The method is allowed to be defined on any parent ...
71
1,660
139
1,799
# 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,929
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/utils/classtools.py
108,110
65,120
out
_WrappedMethod
110,117
110,117
class _WrappedMethod: """Descriptor which calls its two arguments in succession, correctly handling instance- and class-method calls. It is intended that this class will replace the attribute that ``inner`` previously was on a class or instance. When accessed as that attribute, this descriptor will be...
class _WrappedMethod: """Descriptor which calls its two arguments in succession, correctly handling instance- and class-method calls. It is intended that this class will replace the attribute that ``inner`` previously was on a class or instance. When accessed as that attribute, this descriptor will be...
for callback in self._before: callback.__get__(obj, objtype)(*args, **kwargs) retval = method(*args, **kwargs) for callback in self._after: callback.__get__(obj, objtype)(*args, **kwargs) return retval
for callback in self._before: callback.__get__(obj, objtype)(*args, **kwargs) retval = method(*args, **kwargs) for callback in self._after: callback.__get__(obj, objtype)(*args, **kwargs) return retval
20
628
77
705
# 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,931
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/utils/lazy_tester.py
172,173
44,241
require_in_instance
LazyDependencyManager
173,174
173,174
class LazyDependencyManager(abc.ABC): """A mananger for some optional features that are expensive to import, or to verify the existence of. These objects can be used as Booleans, such as ``if x``, and will evaluate ``True`` if the dependency they test for is available, and ``False`` if not. The presen...
class LazyDependencyManager(abc.ABC): """A mananger for some optional features that are expensive to import, or to verify the existence of. These objects can be used as Booleans, such as ``if x``, and will evaluate ``True`` if the dependency they test for is available, and ``False`` if not. The presen...
def require_in_instance(self, feature_or_class: str) -> Callable[[Type], Type]: ...
def require_in_instance(self, feature_or_class: str) -> Callable[[Type], Type]: ...
8
1,968
30
1,998
# 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,932
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/utils/lazy_tester.py
284,285
241,326
_is_available
LazyImportTester
285,326
285,326
class LazyImportTester(LazyDependencyManager): """A lazy dependency tester for importable Python modules. Any required objects will only be imported at the point that this object is tested for its Boolean value.""" __slots__ = ("_modules",) def __init__( self, name_map_or_modules: Uni...
class LazyImportTester(LazyDependencyManager): """A lazy dependency tester for importable Python modules. Any required objects will only be imported at the point that this object is tested for its Boolean value.""" __slots__ = ("_modules",) def __init__( self, name_map_or_modules: Uni...
failed_modules = {} failed_names = collections.defaultdict(list) for module, names in self._modules.items(): try: imported = importlib.import_module(module) except ModuleNotFoundError as exc: failed_parts = exc.name.split(".") ...
failed_modules = {} failed_names = collections.defaultdict(list) for module, names in self._modules.items(): try: imported = importlib.import_module(module) except ModuleNotFoundError as exc: failed_parts = exc.name.split(".") ...
197
540
520
1,060
# 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,933
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/utils/lazy_tester.py
355,356
326,364
_is_available
LazySubprocessTester
356,364
356,364
class LazySubprocessTester(LazyDependencyManager): """A lazy checker that a command-line tool is available. The command will only be run once, at the point that this object is checked for its Boolean value. """ __slots__ = ("_command",) def __init__( self, command: Union[str, Iter...
class LazySubprocessTester(LazyDependencyManager): """A lazy checker that a command-line tool is available. The command will only be run once, at the point that this object is checked for its Boolean value. """ __slots__ = ("_command",) def __init__( self, command: Union[str, Iter...
try: subprocess.run( self._command, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL ) except (OSError, subprocess.SubprocessError): return False else: return True
try: subprocess.run( self._command, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL ) except (OSError, subprocess.SubprocessError): return False else: return True
15
304
78
382
# 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,934
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/utils/multiprocessing.py
20,21
1,57
local_hardware_info
29,49
21,49
# 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...
if hasattr(os, "sched_getaffinity"): num_cpus = len(os.sched_getaffinity(0)) else: num_cpus = os.cpu_count() if num_cpus is None: num_cpus = 1 else: num_cpus = int(num_cpus / 2) or 1 results = { "python_compiler": platform.python_compiler(), "python_...
"""Basic hardware information about the local machine. Gives actual number of CPU's in the machine, even when hyperthreading is turned on. CPU count defaults to 1 when true count can't be determined. Returns: dict: The hardware information. """ if hasattr(os, "sched_getaffinity"): ...
42
344
193
537
# 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,935
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/utils/parallel.py
60,61
1,183
get_platform_parallel_default
69,82
61,82
# 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...
# Default False on Windows if sys.platform == "win32": parallel_default = False # On macOS default false on Python >=3.8 elif sys.platform == "darwin": parallel_default = False # On linux (and other OSes) default to True else: parallel_default = True return parallel_...
""" Returns the default parallelism flag value for the current platform. Returns: parallel_default: The default parallelism flag value for the current platform. """ # Default False on Windows if sys.platform == "win32": parallel_default = False # On macOS default fa...
42
1,935
104
2,039
# 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,936
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/utils/units.py
21,22
1,144
apply_prefix
41,71
22,71
# 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...
prefactors = { "f": -15, "p": -12, "n": -9, "u": -6, "µ": -6, "m": -3, "k": 3, "M": 6, "G": 9, "T": 12, "P": 15, } if not unit or len(unit) == 1: # for example, "m" can represent meter return value ...
""" Given a SI unit prefix and value, apply the prefix to convert to standard SI unit. Args: value: The number to apply prefix to. unit: String prefix. Returns: Converted value. .. note:: This may induce tiny value error due to internal representation of float...
77
1,105
263
1,368
# 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,937
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/version.py
64,65
1,85
get_version_info
66,84
65,84
# 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...
# Adding the git rev number needs to be done inside # write_version_py(), otherwise the import of scipy.version messes # up the build under Python 3. full_version = VERSION if not os.path.exists(os.path.join(os.path.dirname(ROOT_DIR), ".git")): return full_version try: release =...
"""Get the full version string.""" # Adding the git rev number needs to be done inside # write_version_py(), otherwise the import of scipy.version messes # up the build under Python 3. full_version = VERSION if not os.path.exists(os.path.join(os.path.dirname(ROOT_DIR), ".git")): return ...
63
652
214
866
# 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,940
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/visualization/bloch.py
89,90
63,97
draw
Arrow3D
90,97
90,97
class Arrow3D(Patch3D, FancyArrowPatch): """Makes a fancy arrow""" # pylint: disable=missing-function-docstring,invalid-name # Nasty hack around a poorly implemented deprecation warning in Matplotlib 3.5 that issues two # deprecation warnings if an artist's module does not claim to be part of the belo...
class Arrow3D(Patch3D, FancyArrowPatch): """Makes a fancy arrow""" # pylint: disable=missing-function-docstring,invalid-name # Nasty hack around a poorly implemented deprecation warning in Matplotlib 3.5 that issues two # deprecation warnings if an artist's module does not claim to be part of the belo...
xs3d, ys3d, zs3d = zip(*self._segment3d) x_s, y_s, _ = proj3d.proj_transform(xs3d, ys3d, zs3d, self.axes.M) self._path2d = matplotlib.path.Path(np.column_stack([x_s, y_s])) self.set_positions((x_s[0], y_s[0]), (x_s[1], y_s[1])) FancyArrowPatch.draw(self, renderer)
xs3d, ys3d, zs3d = zip(*self._segment3d) x_s, y_s, _ = proj3d.proj_transform(xs3d, ys3d, zs3d, self.axes.M) self._path2d = matplotlib.path.Path(np.column_stack([x_s, y_s])) self.set_positions((x_s[0], y_s[0]), (x_s[1], y_s[1])) FancyArrowPatch.draw(self, renderer)
23
522
157
679
# 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,945
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/visualization/circuit/qcstyle.py
93,94
26,106
update
StyleDict
94,106
94,106
class StyleDict(dict): """A dictionary for matplotlib styles. Defines additional abbreviations for key accesses, such as allowing ``"ec"`` instead of writing ``"edgecolor"``. """ VALID_FIELDS = { "name", "textcolor", "gatetextcolor", "subtextcolor", "linecol...
class StyleDict(dict): """A dictionary for matplotlib styles. Defines additional abbreviations for key accesses, such as allowing ``"ec"`` instead of writing ``"edgecolor"``. """ VALID_FIELDS = { "name", "textcolor", "gatetextcolor", "subtextcolor", "linecol...
# the attributes "displaycolor" and "displaytext" are dictionaries # themselves, therefore we need to propagate the update down to them nested_attrs = {"displaycolor", "displaytext"} for attr in nested_attrs.intersection(other.keys()): if attr in self.keys(): ...
# the attributes "displaycolor" and "displaytext" are dictionaries # themselves, therefore we need to propagate the update down to them nested_attrs = {"displaycolor", "displaytext"} for attr in nested_attrs.intersection(other.keys()): if attr in self.keys(): ...
49
566
145
711
# 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,949
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/visualization/library.py
21,23
1,38
_generate_circuit_library_visualization
23,38
23,38
# 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...
import matplotlib.pyplot as plt circuit = circuit.decompose() ops = circuit.count_ops() num_nl = circuit.num_nonlocal_gates() _fig, (ax0, ax1) = plt.subplots(2, 1) circuit.draw("mpl", ax=ax0) ax1.axis("off") ax1.grid(visible=None) ax1.table( [[circuit.name], [circuit.width()...
import matplotlib.pyplot as plt circuit = circuit.decompose() ops = circuit.count_ops() num_nl = circuit.num_nonlocal_gates() _fig, (ax0, ax1) = plt.subplots(2, 1) circuit.draw("mpl", ax=ax0) ax1.axis("off") ax1.grid(visible=None) ax1.table( [[circuit.name], [circuit.width()...
40
255
215
470
# 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,953
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/visualization/pulse_v2/device_info.py
91,92
46,96
get_channel_frequency
DrawerBackendInfo
93,96
92,96
class DrawerBackendInfo(ABC): """Backend information to be used for the drawing data generation.""" def __init__( self, name: Optional[str] = None, dt: Optional[float] = None, channel_frequency_map: Optional[Dict[pulse.channels.Channel, float]] = None, qubit_channel_map:...
class DrawerBackendInfo(ABC): """Backend information to be used for the drawing data generation.""" def __init__( self, name: Optional[str] = None, dt: Optional[float] = None, channel_frequency_map: Optional[Dict[pulse.channels.Channel, float]] = None, qubit_channel_map:...
return self._chan_freq_map.get(chan, None)
"""Get frequency of given channel object.""" return self._chan_freq_map.get(chan, None)
3
476
23
499
# 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,954
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/visualization/pulse_v2/device_info.py
99,101
96,147
create_from_backend
OpenPulseBackendInfo
109,147
101,147
class OpenPulseBackendInfo(DrawerBackendInfo): """Drawing information of backend that conforms to OpenPulse specification.""" @classmethod def create_from_backend(cls, backend: Backend): FILL_FUNC_BODY
class OpenPulseBackendInfo(DrawerBackendInfo): """Drawing information of backend that conforms to OpenPulse specification.""" @classmethod def create_from_backend(cls, backend: Backend): """Initialize a class with backend information provided by provider. Args: backend: Backend...
configuration = backend.configuration() defaults = backend.defaults() # load name name = backend.name() # load cycle time dt = configuration.dt # load frequencies chan_freqs = {} chan_freqs.update( {pulse.DriveChannel(qind): freq fo...
"""Initialize a class with backend information provided by provider. Args: backend: Backend object. Returns: OpenPulseBackendInfo: New configured instance. """ configuration = backend.configuration() defaults = backend.defaults() # load ...
96
113
504
617
# 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,955
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/visualization/pulse_v2/drawings.py
111,113
71,125
data_key
ElementaryData
114,118
113,118
class ElementaryData(ABC): """Base class of the pulse visualization interface.""" __hash__ = None def __init__( self, data_type: str | Enum, xvals: np.ndarray, yvals: np.ndarray, channels: Channel | list[Channel] | None = None, meta: dict[str, Any] | None = ...
class ElementaryData(ABC): """Base class of the pulse visualization interface.""" __hash__ = None def __init__( self, data_type: str | Enum, xvals: np.ndarray, yvals: np.ndarray, channels: Channel | list[Channel] | None = None, meta: dict[str, Any] | None = ...
return str( hash((self.__class__.__name__, self.data_type, tuple(self.xvals), tuple(self.yvals))) )
"""Return unique hash of this object.""" return str( hash((self.__class__.__name__, self.data_type, tuple(self.xvals), tuple(self.yvals))) )
7
508
45
553
# 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,956
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/visualization/pulse_v2/events.py
197,198
89,255
get_frame_changes
ChannelEvents
199,227
198,227
class ChannelEvents: """Channel event manager.""" _waveform_group = ( pulse.instructions.Play, pulse.instructions.Delay, pulse.instructions.Acquire, ) _frame_group = ( pulse.instructions.SetFrequency, pulse.instructions.ShiftFrequency, pulse.instructions....
class ChannelEvents: """Channel event manager.""" _waveform_group = ( pulse.instructions.Play, pulse.instructions.Delay, pulse.instructions.Acquire, ) _frame_group = ( pulse.instructions.SetFrequency, pulse.instructions.ShiftFrequency, pulse.instructions....
# TODO parse parametrised FCs correctly sorted_frame_changes = sorted(self._frames.items(), key=lambda x: x[0]) phase = self._init_phase frequency = self._init_frequency for t0, frame_changes in sorted_frame_changes: is_opaque = False pre_phase = phase ...
"""Return frame change type instructions with total frame change amount.""" # TODO parse parametrised FCs correctly sorted_frame_changes = sorted(self._frames.items(), key=lambda x: x[0]) phase = self._init_phase frequency = self._init_frequency for t0, frame_changes in...
105
1,334
325
1,659
# 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,957
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/visualization/pulse_v2/generators/barrier.py
45,48
1,77
gen_barrier
60,77
48,77
# 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...
style = { "alpha": formatter["alpha.barrier"], "zorder": formatter["layer.barrier"], "linewidth": formatter["line_width.barrier"], "linestyle": formatter["line_style.barrier"], "color": formatter["color.barrier"], } line = drawings.LineData( data_type=types.L...
"""Generate the barrier from provided relative barrier instruction. Stylesheets: - The `barrier` style is applied. Args: data: Barrier instruction data to draw. formatter: Dictionary of stylesheet settings. device: Backend configuration. Returns: List of `LineDa...
27
556
188
744
# 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,958
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/visualization/pulse_v2/generators/chart.py
81,84
1,209
gen_chart_name
97,118
84,118
# 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...
style = { "zorder": formatter["layer.axis_label"], "color": formatter["color.axis_label"], "size": formatter["text_size.axis_label"], "va": "center", "ha": "right", } text = drawings.TextData( data_type=types.LabelType.CH_NAME, channels=data.channels,...
"""Generate the name of chart. Stylesheets: - The `axis_label` style is applied. Args: data: Chart axis data to draw. formatter: Dictionary of stylesheet settings. device: Backend configuration. Returns: List of `TextData` drawings. """ style = { ...
27
1,696
182
1,878
# 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,960
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/visualization/pulse_v2/generators/snapshot.py
45,50
1,134
gen_snapshot_name
64,85
50,85
# 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...
style = { "zorder": formatter["layer.snapshot"], "color": formatter["color.snapshot"], "size": formatter["text_size.annotate"], "va": "center", "ha": "center", } text = drawings.TextData( data_type=types.LabelType.SNAPSHOT, channels=data.inst.channel,...
"""Generate the name of snapshot. Stylesheets: - The `snapshot` style is applied for snapshot symbol. - The `annotate` style is applied for label font size. Args: data: Snapshot instruction data to draw. formatter: Dictionary of stylesheet settings. device: Backend ...
27
1,047
189
1,236
# 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,964
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/visualization/pulse_v2/plotters/base_plotter.py
37,39
21,54
draw
BasePlotter
40,42
39,42
class BasePlotter(ABC): """Base class of Qiskit plotter.""" def __init__(self, canvas: core.DrawerCanvas): """Create new plotter. Args: canvas: Configured drawer canvas object. """ self.canvas = canvas @abstractmethod def initialize_canvas(self): ""...
class BasePlotter(ABC): """Base class of Qiskit plotter.""" def __init__(self, canvas: core.DrawerCanvas): """Create new plotter. Args: canvas: Configured drawer canvas object. """ self.canvas = canvas @abstractmethod def initialize_canvas(self): ""...
raise NotImplementedError
"""Output drawing objects stored in canvas object.""" raise NotImplementedError
2
245
11
256
# 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,965
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/visualization/pulse_v2/plotters/matplotlib.py
75,76
28,203
draw
Mpl2DPlotter
77,187
76,187
class Mpl2DPlotter(BasePlotter): """Matplotlib API for pulse drawer. This plotter places canvas charts along y axis of 2D canvas with vertical offset. Each chart is map to X-Y axis of the canvas. """ def __init__(self, canvas: core.DrawerCanvas, axis: Optional[plt.Axes] = None): """Create ...
class Mpl2DPlotter(BasePlotter): """Matplotlib API for pulse drawer. This plotter places canvas charts along y axis of 2D canvas with vertical offset. Each chart is map to X-Y axis of the canvas. """ def __init__(self, canvas: core.DrawerCanvas, axis: Optional[plt.Axes] = None): """Create ...
# axis configuration axis_config = self.canvas.layout["time_axis_map"]( time_window=self.canvas.time_range, axis_breaks=self.canvas.time_breaks, dt=self.canvas.device.dt, ) current_y = 0 margin_y = self.canvas.formatter["margin.between_channel...
"""Output drawings stored in canvas object.""" # axis configuration axis_config = self.canvas.layout["time_axis_map"]( time_window=self.canvas.time_range, axis_breaks=self.canvas.time_breaks, dt=self.canvas.device.dt, ) current_y = 0 m...
253
666
1,320
1,986
# 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,967
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/visualization/pulse_v2/stylesheet.py
47,48
38,84
update
QiskitPulseStyle
48,53
48,53
class QiskitPulseStyle(dict): """Stylesheet for pulse drawer.""" def __init__(self): super().__init__() # to inform which stylesheet is applied. some plotter may not support specific style. self.stylesheet = None self.update(default_style()) def update(self, __m: Mapping[st...
class QiskitPulseStyle(dict): """Stylesheet for pulse drawer.""" def __init__(self): super().__init__() # to inform which stylesheet is applied. some plotter may not support specific style. self.stylesheet = None self.update(default_style()) def update(self, __m: Mapping[st...
super().update(__m, **kwargs) for key, value in __m.items(): self.__setitem__(key, value) self.stylesheet = __m.__class__.__name__
super().update(__m, **kwargs) for key, value in __m.items(): self.__setitem__(key, value) self.stylesheet = __m.__class__.__name__
12
385
54
439
# 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,970
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/visualization/timeline/drawings.py
120,122
80,142
data_key
ElementaryData
123,135
122,135
class ElementaryData(ABC): """Base class of the scheduled circuit visualization object. Note that drawings are mutable. """ __hash__ = None def __init__( self, data_type: Union[str, Enum], xvals: Union[np.ndarray, List[types.Coordinate]], yvals: Union[np.ndarray, L...
class ElementaryData(ABC): """Base class of the scheduled circuit visualization object. Note that drawings are mutable. """ __hash__ = None def __init__( self, data_type: Union[str, Enum], xvals: Union[np.ndarray, List[types.Coordinate]], yvals: Union[np.ndarray, L...
return str( hash( ( self.__class__.__name__, self.data_type, tuple(self.bits), tuple(self.xvals), tuple(self.yvals), ) ) )
"""Return unique hash of this object.""" return str( hash( ( self.__class__.__name__, self.data_type, tuple(self.bits), tuple(self.xvals), tuple(self.yvals), ) ...
12
498
78
576
# 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,973
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/visualization/timeline/layouts.py
74,75
1,116
qreg_creg_descending
85,90
75,90
# 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...
return [x for x in bits[::-1] if isinstance(x, circuit.Qubit)] + [ x for x in bits[::-1] if isinstance(x, circuit.Clbit) ]
"""Sort bits by descending order. Bit order becomes Q_N, Q_N-1, ..., Cl_N, Cl_N-1, ... Args: bits: List of bits to sort. Returns: Sorted bits. """ return [x for x in bits[::-1] if isinstance(x, circuit.Qubit)] + [ x for x in bits[::-1] if isinstance(x, circuit.Clbit) ...
20
966
61
1,027
# 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,974
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/visualization/timeline/plotters/base_plotter.py
36,38
21,59
draw
BasePlotter
39,41
38,41
class BasePlotter(ABC): """Base class of Qiskit plotter.""" def __init__(self, canvas: core.DrawerCanvas): """Create new plotter. Args: canvas: Configured drawer canvas object. """ self.canvas = canvas @abstractmethod def initialize_canvas(self): """...
class BasePlotter(ABC): """Base class of Qiskit plotter.""" def __init__(self, canvas: core.DrawerCanvas): """Create new plotter. Args: canvas: Configured drawer canvas object. """ self.canvas = canvas @abstractmethod def initialize_canvas(self): """...
raise NotImplementedError
"""Output drawings stored in canvas object.""" raise NotImplementedError
2
296
11
307
# 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,975
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/visualization/timeline/plotters/matplotlib.py
87,88
31,194
draw
MplPlotter
89,139
88,139
class MplPlotter(BasePlotter): """Matplotlib API for pulse drawer. This plotter arranges bits along y axis of 2D canvas with vertical offset. """ def __init__(self, canvas: core.DrawerCanvas, axis: Optional[plt.Axes] = None): """Create new plotter. Args: canvas: Configured...
class MplPlotter(BasePlotter): """Matplotlib API for pulse drawer. This plotter arranges bits along y axis of 2D canvas with vertical offset. """ def __init__(self, canvas: core.DrawerCanvas, axis: Optional[plt.Axes] = None): """Create new plotter. Args: canvas: Configured...
for _, data in self.canvas.collections: xvals = np.asarray(data.xvals, dtype=float) yvals = np.asarray(data.yvals, dtype=float) offsets = [self.canvas.assigned_coordinates[bit] for bit in data.bits] if isinstance(data, drawings.BoxData): # box da...
"""Output drawings stored in canvas object.""" for _, data in self.canvas.collections: xvals = np.asarray(data.xvals, dtype=float) yvals = np.asarray(data.yvals, dtype=float) offsets = [self.canvas.assigned_coordinates[bit] for bit in data.bits] if isins...
143
1,270
611
1,881
# 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,977
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/visualization/timeline/stylesheet.py
70,72
45,91
generator
QiskitTimelineStyle
73,80
72,80
class QiskitTimelineStyle(dict): """Stylesheet for pulse drawer.""" def __init__(self): super().__init__() # to inform which stylesheet is applied. some plotter may not support specific style. self.stylesheet = None self.update(default_style()) def update(self, __m: Mapping...
class QiskitTimelineStyle(dict): """Stylesheet for pulse drawer.""" def __init__(self): super().__init__() # to inform which stylesheet is applied. some plotter may not support specific style. self.stylesheet = None self.update(default_style()) def update(self, __m: Mapping...
sub_dict = {} for key, value in self.items(): sub_keys = key.split(".") if sub_keys[0] == "generator": sub_dict[".".join(sub_keys[1:])] = value return sub_dict
"""Return generator field of style dictionary.""" sub_dict = {} for key, value in self.items(): sub_keys = key.split(".") if sub_keys[0] == "generator": sub_dict[".".join(sub_keys[1:])] = value return sub_dict
20
365
76
441
# 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,979
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/visualization/transition_visualization.py
107,108
33,124
get_axisangle
_Quaternion
109,114
108,114
class _Quaternion: """For calculating vectors on unit sphere""" def __init__(self): self._val = None @staticmethod def from_axisangle(theta, v): """Create quaternion from axis""" v = _normalize(v) new_quaternion = _Quaternion() new_quaternion._axisangle_to_q(th...
class _Quaternion: """For calculating vectors on unit sphere""" def __init__(self): self._val = None @staticmethod def from_axisangle(theta, v): """Create quaternion from axis""" v = _normalize(v) new_quaternion = _Quaternion() new_quaternion._axisangle_to_q(th...
w, v = self._val[0], self._val[1:] theta = acos(w) * 2.0 return theta, _normalize(v)
"""Returns angle and vector of quaternion""" w, v = self._val[0], self._val[1:] theta = acos(w) * 2.0 return theta, _normalize(v)
13
1,006
52
1,058
# 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,980
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/qiskit/visualization/utils.py
18,20
1,50
_trim
21,32
20,32
# 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...
import PIL background = PIL.Image.new(image.mode, image.size, image.getpixel((0, 0))) diff = PIL.ImageChops.difference(image, background) diff = PIL.ImageChops.add(diff, diff, 2.0, -100) bbox = diff.getbbox() if bbox: image = image.crop(bbox) return image
"""Trim a PIL image and remove white space.""" import PIL background = PIL.Image.new(image.mode, image.size, image.getpixel((0, 0))) diff = PIL.ImageChops.difference(image, background) diff = PIL.ImageChops.add(diff, diff, 2.0, -100) bbox = diff.getbbox() if bbox: image = image.crop...
28
444
127
571
# 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,982
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/tools/find_deprecated.py
165,166
136,181
visit_FunctionDef
DecoratorVisitor
167,174
166,174
class DecoratorVisitor(ast.NodeVisitor): """ Node visitor for finding deprecation decorator Args: filename: Name of the file to analyze """ def __init__(self, filename: Path): self.filename = short_path(filename) self.deprecations: list[Deprecation] = [] @staticmethod ...
class DecoratorVisitor(ast.NodeVisitor): """ Node visitor for finding deprecation decorator Args: filename: Name of the file to analyze """ def __init__(self, filename: Path): self.filename = short_path(filename) self.deprecations: list[Deprecation] = [] @staticmethod ...
self.deprecations += [ DeprecationDecorator(self.filename, cast(ast.Call, d_node), node) for d_node in node.decorator_list if DecoratorVisitor.is_deprecation_decorator(d_node) ] ast.NodeVisitor.generic_visit(self, node)
"""Visitor for function declarations""" self.deprecations += [ DeprecationDecorator(self.filename, cast(ast.Call, d_node), node) for d_node in node.decorator_list if DecoratorVisitor.is_deprecation_decorator(d_node) ] ast.NodeVisitor.generic_visit(self...
16
426
96
522
#!/usr/bin/env python3 # 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 modifica...
#!/usr/bin/env python3 # 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 modifica...
30,983
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/tools/find_deprecated.py
41,43
36,47
location_str
Deprecation
44,47
43,47
class Deprecation: """ Root class for Deprecation classes. """ @property def location_str(self) -> str: FILL_FUNC_BODY
class Deprecation: """ Root class for Deprecation classes. """ @property def location_str(self) -> str: """String with the location of the deprecated decorator <filename>:<line number>""" FILL_FUNC_BODY
return f"{self.filename}:{self.lineno}"
"""String with the location of the deprecated decorator <filename>:<line number>""" return f"{self.filename}:{self.lineno}"
2
72
21
93
#!/usr/bin/env python3 # 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 modifica...
#!/usr/bin/env python3 # 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 modifica...
30,984
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/tools/find_deprecated.py
115,117
100,136
target
DeprecationCall
118,126
117,126
class DeprecationCall(Deprecation): """ Deprecation call, representing a single deprecation call. Args: decorator_call: deprecation call. """ def __init__(self, filename: Path, decorator_call: ast.Call) -> None: self.filename = filename self.decorator_node = decorator_call ...
class DeprecationCall(Deprecation): """ Deprecation call, representing a single deprecation call. Args: decorator_call: deprecation call. """ def __init__(self, filename: Path, decorator_call: ast.Call) -> None: self.filename = filename self.decorator_node = decorator_call ...
if not self._target: arg = self.decorator_node.args.__getitem__(0) if isinstance(arg, ast.Attribute): self._target = f"{arg.value.id}.{arg.attr}" if isinstance(arg, ast.Name): self._target = arg.id return self._target
"""what's deprecated.""" if not self._target: arg = self.decorator_node.args.__getitem__(0) if isinstance(arg, ast.Attribute): self._target = f"{arg.value.id}.{arg.attr}" if isinstance(arg, ast.Name): self._target = arg.id retur...
20
276
94
370
#!/usr/bin/env python3 # 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 modifica...
#!/usr/bin/env python3 # 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 modifica...
30,985
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/tools/find_deprecated.py
216,218
181,226
find_deprecations
DeprecationCollection
219,226
218,226
class DeprecationCollection: """ A collection of :class:~.Deprecation Args: dirname: Directory name that would be checked recursively for deprecations. """ def __init__(self, dirname: Path): self.dirname = dirname self._deprecations: list[Deprecation] | None = None ...
class DeprecationCollection: """ A collection of :class:~.Deprecation Args: dirname: Directory name that would be checked recursively for deprecations. """ def __init__(self, dirname: Path): self.dirname = dirname self._deprecations: list[Deprecation] | None = None ...
code = Path(file_name).read_text() mod = ast.parse(code, file_name) decorator_visitor = DecoratorVisitor(file_name) decorator_visitor.visit(mod) return decorator_visitor.deprecations
"""Runs the deprecation finder on file_name""" code = Path(file_name).read_text() mod = ast.parse(code, file_name) decorator_visitor = DecoratorVisitor(file_name) decorator_visitor.visit(mod) return decorator_visitor.deprecations
13
475
79
554
#!/usr/bin/env python3 # 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 modifica...
#!/usr/bin/env python3 # 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 modifica...
30,986
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/tools/find_deprecated.py
75,77
47,100
pending
DeprecationDecorator
78,89
77,89
class DeprecationDecorator(Deprecation): """ Deprecation decorator, representing a single deprecation decorator. Args: filename: where is the deprecation. decorator_node: AST node of the decorator call. func_node: AST node of the decorated call. """ def __init__( se...
class DeprecationDecorator(Deprecation): """ Deprecation decorator, representing a single deprecation decorator. Args: filename: where is the deprecation. decorator_node: AST node of the decorator call. func_node: AST node of the decorated call. """ def __init__( se...
if not self._pending: self._pending = next( ( kwarg.value.value for kwarg in self.decorator_node.keywords if kwarg.arg == "pending" ), False, ) return self._pending
"""If it is a pending deprecation.""" if not self._pending: self._pending = next( ( kwarg.value.value for kwarg in self.decorator_node.keywords if kwarg.arg == "pending" ), False, ...
21
396
84
480
#!/usr/bin/env python3 # 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 modifica...
#!/usr/bin/env python3 # 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 modifica...
30,987
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/tools/find_optional_imports.py
23,24
1,83
_main
24,81
24,81
#!/usr/bin/env python3 # 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 modifica...
#!/usr/bin/env python3 # 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 modifica...
optional_imports = [ "networkx", "sympy", "pydot", "pygments", "ipywidgets", "scipy.linalg", "scipy.optimize", "scipy.stats", "matplotlib", "qiskit_aer", "qiskit.providers.ibmq", "qiskit.ignis", "qiskit.aqua", ...
optional_imports = [ "networkx", "sympy", "pydot", "pygments", "ipywidgets", "scipy.linalg", "scipy.optimize", "scipy.stats", "matplotlib", "qiskit_aer", "qiskit.providers.ibmq", "qiskit.ignis", "qiskit.aqua", ...
120
236
523
759
#!/usr/bin/env python3 # 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 modifica...
#!/usr/bin/env python3 # 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 modifica...
30,988
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/tools/find_stray_release_notes.py
43,44
1,59
_main
44,57
44,57
#!/usr/bin/env python3 # 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 modifica...
#!/usr/bin/env python3 # 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 modifica...
parser = argparse.ArgumentParser(description="Find any stray release notes.") _args = parser.parse_args() files = discover_files() with multiprocessing.Pool() as pool: res = pool.map(validate_path, files) failed_files = [x for x in res if x is not None] if len(failed_files) > 0: ...
parser = argparse.ArgumentParser(description="Find any stray release notes.") _args = parser.parse_args() files = discover_files() with multiprocessing.Pool() as pool: res = pool.map(validate_path, files) failed_files = [x for x in res if x is not None] if len(failed_files) > 0: ...
52
418
162
580
#!/usr/bin/env python3 # 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 modifica...
#!/usr/bin/env python3 # 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 modifica...
30,989
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/tools/pgo_scripts/test_utility_scale.py
32,33
1,94
_main
33,92
33,92
#!/usr/bin/env python3 # 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 modific...
#!/usr/bin/env python3 # 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 modific...
cmap = CouplingMap.from_heavy_hex(9) cz_backend = GenericBackendV2( cmap.size(), ["rz", "x", "sx", "cz", "id"], coupling_map=cmap, control_flow=True, seed=12345678942, ) ecr_backend = GenericBackendV2( cmap.size(), ["rz", "x", "sx", "ecr", "id"], ...
cmap = CouplingMap.from_heavy_hex(9) cz_backend = GenericBackendV2( cmap.size(), ["rz", "x", "sx", "cz", "id"], coupling_map=cmap, control_flow=True, seed=12345678942, ) ecr_backend = GenericBackendV2( cmap.size(), ["rz", "x", "sx", "ecr", "id"], ...
131
336
1,001
1,337
#!/usr/bin/env python3 # 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 modific...
#!/usr/bin/env python3 # 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 modific...
30,990
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/tools/subunit_to_junit.py
29,38
1,157
filter_by_result
57,92
38,92
#!/usr/bin/env python3 # 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 ...
#!/usr/bin/env python3 # 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 ...
if protocol_version == 1: sys.stderr.write("Subunit protocol version 2 must be used") sys.exit(1) if passthrough: passthrough_stream = sys.stdout else: passthrough_stream = None if forward: forward_stream = sys.stdout else: forward_stream = None ...
"""Filter an input stream using a test result. :param callable result_factory: A callable that when passed an output stream returns a TestResult. It is expected that this result will output to the given stream. :param str output_path: A path send output to. If None, output will be go ...
63
1,280
295
1,575
#!/usr/bin/env python3 # 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 ...
#!/usr/bin/env python3 # 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 ...
30,991
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit
/home/hieuvd/dung_repo/raw/stars_02/Qiskit_qiskit/qiskit/tools/verify_headers.py
106,107
1,133
_main
107,131
107,131
#!/usr/bin/env python3 # 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 modifica...
#!/usr/bin/env python3 # 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 modifica...
default_path = os.path.join( os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "qiskit" ) parser = argparse.ArgumentParser(description="Check file headers.") parser.add_argument( "paths", type=str, nargs="*", default=[default_path], help="Paths ...
default_path = os.path.join( os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "qiskit" ) parser = argparse.ArgumentParser(description="Check file headers.") parser.add_argument( "paths", type=str, nargs="*", default=[default_path], help="Paths ...
72
1,280
305
1,585
#!/usr/bin/env python3 # 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 modifica...
#!/usr/bin/env python3 # 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 modifica...
30,999
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet/nanodet/data/dataset/yolo.py
65,66
49,173
yolo_to_coco
YoloDataset
71,153
66,153
class YoloDataset(CocoDataset): def __init__(self, class_names, **kwargs): self.class_names = class_names super(YoloDataset, self).__init__(**kwargs) @staticmethod def _find_image( image_prefix: str, image_types: Sequence[str] = (".png", ".jpg", ".jpeg", ".bmp", ".tiff"), ...
class YoloDataset(CocoDataset): def __init__(self, class_names, **kwargs): self.class_names = class_names super(YoloDataset, self).__init__(**kwargs) @staticmethod def _find_image( image_prefix: str, image_types: Sequence[str] = (".png", ".jpg", ".jpeg", ".bmp", ".tiff"), ...
logging.info("loading annotations into memory...") tic = time.time() ann_file_names = get_file_list(ann_path, type=".txt") logging.info("Found {} annotation files.".format(len(ann_file_names))) image_info = [] categories = [] annotations = [] for idx, supe...
""" convert yolo annotations to coco_api :param ann_path: :return: """ logging.info("loading annotations into memory...") tic = time.time() ann_file_names = get_file_list(ann_path, type=".txt") logging.info("Found {} annotation files.".format(len(a...
247
506
948
1,454
# Copyright 2023 cansik. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, soft...
# Copyright 2023 cansik. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, soft...
31,001
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet/nanodet/evaluator/coco_detection.py
31,32
1,150
xyxy2xywh
37,45
32,45
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
return [ bbox[0], bbox[1], bbox[2] - bbox[0], bbox[3] - bbox[1], ]
""" change bbox to coco format :param bbox: [x1, y1, x2, y2] :return: [x, y, w, h] """ return [ bbox[0], bbox[1], bbox[2] - bbox[0], bbox[3] - bbox[1], ]
11
1,570
57
1,627
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
31,002
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet/nanodet/evaluator/coco_detection.py
76,77
45,150
evaluate
CocoDetectionEvaluator
77,150
77,150
class CocoDetectionEvaluator: def __init__(self, dataset): assert hasattr(dataset, "coco_api") self.class_names = dataset.class_names self.coco_api = dataset.coco_api self.cat_ids = dataset.cat_ids self.metric_names = ["mAP", "AP_50", "AP_75", "AP_small", "AP_m", "AP_l"] ...
class CocoDetectionEvaluator: def __init__(self, dataset): assert hasattr(dataset, "coco_api") self.class_names = dataset.class_names self.coco_api = dataset.coco_api self.cat_ids = dataset.cat_ids self.metric_names = ["mAP", "AP_50", "AP_75", "AP_small", "AP_m", "AP_l"] ...
results_json = self.results2json(results) if len(results_json) == 0: warnings.warn( "Detection result is empty! Please check whether " "training set is too small (need to increase val_interval " "in config and train more epochs). Or check annot...
results_json = self.results2json(results) if len(results_json) == 0: warnings.warn( "Detection result is empty! Please check whether " "training set is too small (need to increase val_interval " "in config and train more epochs). Or check annot...
261
350
1,003
1,353
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
31,003
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet/nanodet/model/backbone/timm_wrapper.py
60,61
22,67
forward
TIMMWrapper
61,67
61,67
class TIMMWrapper(nn.Module): """Wrapper to use backbones in timm https://github.com/rwightman/pytorch-image-models.""" def __init__( self, model_name, features_only=True, pretrained=True, checkpoint_path="", in_channels=3, **kwargs, ): tr...
class TIMMWrapper(nn.Module): """Wrapper to use backbones in timm https://github.com/rwightman/pytorch-image-models.""" def __init__( self, model_name, features_only=True, pretrained=True, checkpoint_path="", in_channels=3, **kwargs, ): tr...
outs = self.timm(x) if isinstance(outs, (list, tuple)): features = tuple(outs) else: features = (outs,) return features
outs = self.timm(x) if isinstance(outs, (list, tuple)): features = tuple(outs) else: features = (outs,) return features
16
348
54
402
# Copyright 2022 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
# Copyright 2022 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
31,004
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet/nanodet/model/fpn/pan.py
64,65
21,95
forward
PAN
66,95
65,95
class PAN(FPN): """Path Aggregation Network for Instance Segmentation. This is an implementation of the `PAN in Path Aggregation Network <https://arxiv.org/abs/1803.01534>`_. Args: in_channels (List[int]): Number of input channels per scale. out_channels (int): Number of output channel...
class PAN(FPN): """Path Aggregation Network for Instance Segmentation. This is an implementation of the `PAN in Path Aggregation Network <https://arxiv.org/abs/1803.01534>`_. Args: in_channels (List[int]): Number of input channels per scale. out_channels (int): Number of output channel...
assert len(inputs) == len(self.in_channels) # build laterals laterals = [ lateral_conv(inputs[i + self.start_level]) for i, lateral_conv in enumerate(self.lateral_convs) ] # build top-down path used_backbone_levels = len(laterals) for i i...
"""Forward function.""" assert len(inputs) == len(self.in_channels) # build laterals laterals = [ lateral_conv(inputs[i + self.start_level]) for i, lateral_conv in enumerate(self.lateral_convs) ] # build top-down path used_backbone_levels...
93
429
360
789
# Modification 2020 RangiLyu # Copyright 2018-2019 Open-MMLab. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicabl...
# Modification 2020 RangiLyu # Copyright 2018-2019 Open-MMLab. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicabl...
31,005
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet/nanodet/model/loss/utils.py
26,27
1,94
weight_reduce_loss
38,55
27,55
import functools import torch.nn.functional as F def reduce_loss(loss, reduction): """Reduce loss as specified. Args: loss (Tensor): Elementwise loss tensor. reduction (str): Options are "none", "mean" and "sum". Return: Tensor: Reduced loss tensor. """ reduction_enum = ...
import functools import torch.nn.functional as F def reduce_loss(loss, reduction): """Reduce loss as specified. Args: loss (Tensor): Elementwise loss tensor. reduction (str): Options are "none", "mean" and "sum". Return: Tensor: Reduced loss tensor. """ reduction_enum = ...
# if weight is specified, apply element-wise weight if weight is not None: loss = loss * weight # if avg_factor is not specified, just reduce the loss if avg_factor is None: loss = reduce_loss(loss, reduction) else: # if reduction is mean, then average the loss by avg_factor...
"""Apply element-wise weight and reduce loss. Args: loss (Tensor): Element-wise loss. weight (Tensor): Element-wise weights. reduction (str): Same as built-in losses of PyTorch. avg_factor (float): Avarage factor when computing the mean of losses. Returns: Tensor: P...
83
749
179
928
import functools import torch.nn.functional as F def reduce_loss(loss, reduction): """Reduce loss as specified. Args: loss (Tensor): Elementwise loss tensor. reduction (str): Options are "none", "mean" and "sum". Return: Tensor: Reduced loss tensor. """ reduction_enum = ...
import functools import torch.nn.functional as F def reduce_loss(loss, reduction): """Reduce loss as specified. Args: loss (Tensor): Elementwise loss tensor. reduction (str): Options are "none", "mean" and "sum". Return: Tensor: Reduced loss tensor. """ reduction_enum = ...
31,006
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet/nanodet/model/module/activation.py
32,33
1,42
act_layers
33,42
33,42
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
assert name in activations.keys() if name == "LeakyReLU": return nn.LeakyReLU(negative_slope=0.1, inplace=True) elif name == "GELU": return nn.GELU() elif name == "PReLU": return nn.PReLU() else: return activations[name](inplace=True)
assert name in activations.keys() if name == "LeakyReLU": return nn.LeakyReLU(negative_slope=0.1, inplace=True) elif name == "GELU": return nn.GELU() elif name == "PReLU": return nn.PReLU() else: return activations[name](inplace=True)
26
351
116
467
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
31,007
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet/nanodet/model/module/init_weights.py
23,24
1,44
xavier_init
24,33
24,33
# Modification 2020 RangiLyu # Copyright 2018-2019 Open-MMLab. import torch.nn as nn def kaiming_init( module, a=0, mode="fan_out", nonlinearity="relu", bias=0, distribution="normal" ): assert distribution in ["uniform", "normal"] if distribution == "uniform": nn.init.kaiming_uniform_( ...
# Modification 2020 RangiLyu # Copyright 2018-2019 Open-MMLab. import torch.nn as nn def kaiming_init( module, a=0, mode="fan_out", nonlinearity="relu", bias=0, distribution="normal" ): assert distribution in ["uniform", "normal"] if distribution == "uniform": nn.init.kaiming_uniform_( ...
assert distribution in ["uniform", "normal"] if distribution == "uniform": nn.init.xavier_uniform_(module.weight, gain=gain) else: nn.init.xavier_normal_(module.weight, gain=gain) if hasattr(module, "bias") and module.bias is not None: nn.init.constant_(module.bias, bias)
assert distribution in ["uniform", "normal"] if distribution == "uniform": nn.init.xavier_uniform_(module.weight, gain=gain) else: nn.init.xavier_normal_(module.weight, gain=gain) if hasattr(module, "bias") and module.bias is not None: nn.init.constant_(module.bias, bias)
24
415
113
528
# Modification 2020 RangiLyu # Copyright 2018-2019 Open-MMLab. import torch.nn as nn def kaiming_init( module, a=0, mode="fan_out", nonlinearity="relu", bias=0, distribution="normal" ): assert distribution in ["uniform", "normal"] if distribution == "uniform": nn.init.kaiming_uniform_( ...
# Modification 2020 RangiLyu # Copyright 2018-2019 Open-MMLab. import torch.nn as nn def kaiming_init( module, a=0, mode="fan_out", nonlinearity="relu", bias=0, distribution="normal" ): assert distribution in ["uniform", "normal"] if distribution == "uniform": nn.init.kaiming_uniform_( ...
31,008
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet/nanodet/model/module/norm.py
12,13
1,56
build_norm_layer
28,56
13,56
import torch.nn as nn norm_cfg = { # format: layer_type: (abbreviation, module) "BN": ("bn", nn.BatchNorm2d), "SyncBN": ("bn", nn.SyncBatchNorm), "GN": ("gn", nn.GroupNorm), # and potentially 'SN' } def build_norm_layer(cfg, num_features, postfix=""): FILL_FUNC_BODY
import torch.nn as nn norm_cfg = { # format: layer_type: (abbreviation, module) "BN": ("bn", nn.BatchNorm2d), "SyncBN": ("bn", nn.SyncBatchNorm), "GN": ("gn", nn.GroupNorm), # and potentially 'SN' } def build_norm_layer(cfg, num_features, postfix=""): """Build normalization layer Args: ...
assert isinstance(cfg, dict) and "type" in cfg cfg_ = cfg.copy() layer_type = cfg_.pop("type") if layer_type not in norm_cfg: raise KeyError("Unrecognized norm type {}".format(layer_type)) else: abbr, norm_layer = norm_cfg[layer_type] if norm_layer is None: raise...
"""Build normalization layer Args: cfg (dict): cfg should contain: type (str): identify norm layer type. layer args: args needed to instantiate a norm layer. requires_grad (bool): [optional] whether stop gradient updates num_features (int): number of channels...
84
249
337
586
import torch.nn as nn norm_cfg = { # format: layer_type: (abbreviation, module) "BN": ("bn", nn.BatchNorm2d), "SyncBN": ("bn", nn.SyncBatchNorm), "GN": ("gn", nn.GroupNorm), # and potentially 'SN' } def build_norm_layer(cfg, num_features, postfix=""): FILL_FUNC_BODY
import torch.nn as nn norm_cfg = { # format: layer_type: (abbreviation, module) "BN": ("bn", nn.BatchNorm2d), "SyncBN": ("bn", nn.SyncBatchNorm), "GN": ("gn", nn.GroupNorm), # and potentially 'SN' } def build_norm_layer(cfg, num_features, postfix=""): """Build normalization layer Args: ...
31,009
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet/nanodet/model/weight_averager/ema.py
41,42
14,81
apply_to
ExpMovingAverager
43,50
42,50
class ExpMovingAverager(object): """Exponential Moving Average. Args: decay (float): EMA decay factor, should be in [0, 1]. A decay of 0 corresponds to always using the latest value (no EMA) and a decay of 1 corresponds to not updating weights after initialization. Default to 0....
class ExpMovingAverager(object): """Exponential Moving Average. Args: decay (float): EMA decay factor, should be in [0, 1]. A decay of 0 corresponds to always using the latest value (no EMA) and a decay of 1 corresponds to not updating weights after initialization. Default to 0....
with torch.no_grad(): for name, val in self._get_model_state_iterator(model): assert ( name in self.state ), f"Name {name} not exist, available names are {self.state.keys()}" val.copy_(self.state[name])
"""Apply EMA state to the model.""" with torch.no_grad(): for name, val in self._get_model_state_iterator(model): assert ( name in self.state ), f"Name {name} not exist, available names are {self.state.keys()}" val.copy_(sel...
22
802
83
885
# Copyright 2021 RangiLyu. All rights reserved. # ===================================================================== # Modified from: https://github.com/facebookresearch/d2go # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved # Licensed under the Apache License, Version 2.0 (the "License") import...
# Copyright 2021 RangiLyu. All rights reserved. # ===================================================================== # Modified from: https://github.com/facebookresearch/d2go # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved # Licensed under the Apache License, Version 2.0 (the "License") import...
31,010
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet/nanodet/optim/builder.py
11,12
1,77
build_optimizer
25,77
12,77
import copy import logging import torch from torch.nn import GroupNorm, LayerNorm from torch.nn.modules.batchnorm import _BatchNorm NORMS = (GroupNorm, LayerNorm, _BatchNorm) def build_optimizer(model, config): FILL_FUNC_BODY
import copy import logging import torch from torch.nn import GroupNorm, LayerNorm from torch.nn.modules.batchnorm import _BatchNorm NORMS = (GroupNorm, LayerNorm, _BatchNorm) def build_optimizer(model, config): """Build optimizer from config. Supports customised parameter-level hyperparameters. The con...
config = copy.deepcopy(config) param_dict = {} no_norm_decay = config.pop("no_norm_decay", False) no_bias_decay = config.pop("no_bias_decay", False) param_level_cfg = config.pop("param_level_cfg", {}) base_lr = config.get("lr", None) base_wd = config.get("weight_decay", None) name = con...
"""Build optimizer from config. Supports customised parameter-level hyperparameters. The config should be like: >>> optimizer: >>> name: AdamW >>> lr: 0.001 >>> weight_decay: 0.05 >>> no_norm_decay: True >>> param_level_cfg: # parameter-level config >>> backbone: ...
167
202
694
896
import copy import logging import torch from torch.nn import GroupNorm, LayerNorm from torch.nn.modules.batchnorm import _BatchNorm NORMS = (GroupNorm, LayerNorm, _BatchNorm) def build_optimizer(model, config): FILL_FUNC_BODY
import copy import logging import torch from torch.nn import GroupNorm, LayerNorm from torch.nn.modules.batchnorm import _BatchNorm NORMS = (GroupNorm, LayerNorm, _BatchNorm) def build_optimizer(model, config): """Build optimizer from config. Supports customised parameter-level hyperparameters. The con...
31,011
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet/nanodet/util/check_point.py
73,74
1,112
convert_old_model
74,99
74,99
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
if "pytorch-lightning_version" in old_model_dict: raise ValueError("This model is not old format. No need to convert!") version = pl.__version__ epoch = old_model_dict["epoch"] global_step = old_model_dict["iter"] state_dict = old_model_dict["state_dict"] new_state_dict = OrderedDict() ...
if "pytorch-lightning_version" in old_model_dict: raise ValueError("This model is not old format. No need to convert!") version = pl.__version__ epoch = old_model_dict["epoch"] global_step = old_model_dict["iter"] state_dict = old_model_dict["state_dict"] new_state_dict = OrderedDict() ...
66
947
285
1,232
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
31,012
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet/nanodet/util/config.py
30,31
1,41
load_config
31,36
31,36
from .yacs import CfgNode cfg = CfgNode(new_allowed=True) cfg.save_dir = "./" # common params for NETWORK cfg.model = CfgNode(new_allowed=True) cfg.model.arch = CfgNode(new_allowed=True) cfg.model.arch.backbone = CfgNode(new_allowed=True) cfg.model.arch.fpn = CfgNode(new_allowed=True) cfg.model.arch.head = CfgNode(new...
from .yacs import CfgNode cfg = CfgNode(new_allowed=True) cfg.save_dir = "./" # common params for NETWORK cfg.model = CfgNode(new_allowed=True) cfg.model.arch = CfgNode(new_allowed=True) cfg.model.arch.backbone = CfgNode(new_allowed=True) cfg.model.arch.fpn = CfgNode(new_allowed=True) cfg.model.arch.head = CfgNode(new...
cfg.defrost() cfg.merge_from_file(args_cfg) cfg.freeze()
cfg.defrost() cfg.merge_from_file(args_cfg) cfg.freeze()
3
345
39
384
from .yacs import CfgNode cfg = CfgNode(new_allowed=True) cfg.save_dir = "./" # common params for NETWORK cfg.model = CfgNode(new_allowed=True) cfg.model.arch = CfgNode(new_allowed=True) cfg.model.arch.backbone = CfgNode(new_allowed=True) cfg.model.arch.fpn = CfgNode(new_allowed=True) cfg.model.arch.head = CfgNode(new...
from .yacs import CfgNode cfg = CfgNode(new_allowed=True) cfg.save_dir = "./" # common params for NETWORK cfg.model = CfgNode(new_allowed=True) cfg.model.arch = CfgNode(new_allowed=True) cfg.model.arch.backbone = CfgNode(new_allowed=True) cfg.model.arch.fpn = CfgNode(new_allowed=True) cfg.model.arch.head = CfgNode(new...
31,013
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet/nanodet/util/env_utils.py
8,11
1,66
set_multi_processing
22,66
11,66
import os import platform import warnings import torch.multiprocessing as mp def set_multi_processing( mp_start_method: str = "fork", opencv_num_threads: int = 0, distributed: bool = True ) -> None: FILL_FUNC_BODY
import os import platform import warnings import torch.multiprocessing as mp def set_multi_processing( mp_start_method: str = "fork", opencv_num_threads: int = 0, distributed: bool = True ) -> None: """Set multi-processing related environment. This function is refered from https://github.com/open-mmlab/...
""" # noqa # set multi-process start method as `fork` to speed up the training if platform.system() != "Windows": current_method = mp.get_start_method(allow_none=True) if current_method is not None and current_method != mp_start_method: warnings.warn( f"Multi-pro...
"""Set multi-processing related environment. This function is refered from https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/dl_utils/setup_env.py Args: mp_start_method (str): Set the method which should be used to start child processes. Defaults to 'fork'. opencv...
198
216
621
837
import os import platform import warnings import torch.multiprocessing as mp def set_multi_processing( mp_start_method: str = "fork", opencv_num_threads: int = 0, distributed: bool = True ) -> None: FILL_FUNC_BODY
import os import platform import warnings import torch.multiprocessing as mp def set_multi_processing( mp_start_method: str = "fork", opencv_num_threads: int = 0, distributed: bool = True ) -> None: """Set multi-processing related environment. This function is refered from https://github.com/open-mmlab/...
31,014
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet/nanodet/util/path.py
26,27
1,35
collect_files
27,35
27,35
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
file_paths = [] for maindir, subdir, filename_list in os.walk(path): for filename in filename_list: file_path = os.path.join(maindir, filename) ext = os.path.splitext(file_path)[1] if ext in exts: file_paths.append(file_path) return file_paths
file_paths = [] for maindir, subdir, filename_list in os.walk(path): for filename in filename_list: file_path = os.path.join(maindir, filename) ext = os.path.splitext(file_path)[1] if ext in exts: file_paths.append(file_path) return file_paths
27
232
104
336
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
31,015
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet/nanodet/util/rank_filter.py
16,17
1,24
rank_filter
17,24
17,24
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
def func_filter(local_rank=-1, *args, **kwargs): if local_rank < 1: return func(*args, **kwargs) else: pass return func_filter
def func_filter(local_rank=-1, *args, **kwargs): if local_rank < 1: return func(*args, **kwargs) else: pass return func_filter
15
178
60
238
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
31,016
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet
/home/hieuvd/dung_repo/raw/stars_02/RangiLyu_nanodet/nanodet/tools/convert_old_checkpoint.py
22,23
1,40
parse_args
23,32
23,32
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter, description="Convert .pth model to onnx.", ) parser.add_argument("--file_path", type=str, help="Path to .pth checkpoint.") parser.add_argument("--out_path", type=str, help="Path to .ckpt checkpoint....
parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter, description="Convert .pth model to onnx.", ) parser.add_argument("--file_path", type=str, help="Path to .pth checkpoint.") parser.add_argument("--out_path", type=str, help="Path to .ckpt checkpoint....
24
309
121
430
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
# Copyright 2021 RangiLyu. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, so...
31,017
/home/hieuvd/dung_repo/raw/stars_02/Rayhane-mamah_Tacotron-2/Tacotron-2
/home/hieuvd/dung_repo/raw/stars_02/Rayhane-mamah_Tacotron-2/Tacotron-2/infolog.py
13,14
1,51
init
14,25
14,25
import atexit import json from datetime import datetime from threading import Thread from urllib.request import Request, urlopen _format = '%Y-%m-%d %H:%M:%S.%f' _file = None _run_name = None _slack_url = None def init(filename, run_name, slack_url=None): FILL_FUNC_BODYdef log(msg, end='\n', slack=False): print(msg...
import atexit import json from datetime import datetime from threading import Thread from urllib.request import Request, urlopen _format = '%Y-%m-%d %H:%M:%S.%f' _file = None _run_name = None _slack_url = None def init(filename, run_name, slack_url=None): FILL_FUNC_BODYdef log(msg, end='\n', slack=False): print(msg...
global _file, _run_name, _slack_url _close_logfile() _file = open(filename, 'a') _file = open(filename, 'a') _file.write('\n-----------------------------------------------------------------\n') _file.write('Starting new {} training run\n'.format(run_name)) _file.write('-------------------------------------------...
global _file, _run_name, _slack_url _close_logfile() _file = open(filename, 'a') _file = open(filename, 'a') _file.write('\n-----------------------------------------------------------------\n') _file.write('Starting new {} training run\n'.format(run_name)) _file.write('-------------------------------------------...
26
360
121
481
import atexit import json from datetime import datetime from threading import Thread from urllib.request import Request, urlopen _format = '%Y-%m-%d %H:%M:%S.%f' _file = None _run_name = None _slack_url = None def init(filename, run_name, slack_url=None): FILL_FUNC_BODYdef log(msg, end='\n', slack=False): print(msg...
import atexit import json from datetime import datetime from threading import Thread from urllib.request import Request, urlopen _format = '%Y-%m-%d %H:%M:%S.%f' _file = None _run_name = None _slack_url = None def init(filename, run_name, slack_url=None): FILL_FUNC_BODYdef log(msg, end='\n', slack=False): print(msg...
31,018
/home/hieuvd/dung_repo/raw/stars_02/Rayhane-mamah_Tacotron-2/Tacotron-2
/home/hieuvd/dung_repo/raw/stars_02/Rayhane-mamah_Tacotron-2/Tacotron-2/tacotron/utils/cmudict.py
42,43
1,63
_parse_cmudict
43,57
43,57
import re valid_symbols = [ 'AA', 'AA0', 'AA1', 'AA2', 'AE', 'AE0', 'AE1', 'AE2', 'AH', 'AH0', 'AH1', 'AH2', 'AO', 'AO0', 'AO1', 'AO2', 'AW', 'AW0', 'AW1', 'AW2', 'AY', 'AY0', 'AY1', 'AY2', 'B', 'CH', 'D', 'DH', 'EH', 'EH0', 'EH1', 'EH2', 'ER', 'ER0', 'ER1', 'ER2', 'EY', 'EY0', 'EY1', 'EY2', 'F', 'G', 'HH', 'I...
import re valid_symbols = [ 'AA', 'AA0', 'AA1', 'AA2', 'AE', 'AE0', 'AE1', 'AE2', 'AH', 'AH0', 'AH1', 'AH2', 'AO', 'AO0', 'AO1', 'AO2', 'AW', 'AW0', 'AW1', 'AW2', 'AY', 'AY0', 'AY1', 'AY2', 'B', 'CH', 'D', 'DH', 'EH', 'EH0', 'EH1', 'EH2', 'ER', 'ER0', 'ER1', 'ER2', 'EY', 'EY0', 'EY1', 'EY2', 'F', 'G', 'HH', 'I...
cmudict = {} for line in file: if len(line) and (line[0] >= 'A' and line[0] <= 'Z' or line[0] == "'"): parts = line.split(' ') word = re.sub(_alt_re, '', parts[0]) pronunciation = _get_pronunciation(parts[1]) if pronunciation: if word in cmudict: cmudict[word].append(p...
cmudict = {} for line in file: if len(line) and (line[0] >= 'A' and line[0] <= 'Z' or line[0] == "'"): parts = line.split(' ') word = re.sub(_alt_re, '', parts[0]) pronunciation = _get_pronunciation(parts[1]) if pronunciation: if word in cmudict: cmudict[word].append(p...
46
718
162
880
import re valid_symbols = [ 'AA', 'AA0', 'AA1', 'AA2', 'AE', 'AE0', 'AE1', 'AE2', 'AH', 'AH0', 'AH1', 'AH2', 'AO', 'AO0', 'AO1', 'AO2', 'AW', 'AW0', 'AW1', 'AW2', 'AY', 'AY0', 'AY1', 'AY2', 'B', 'CH', 'D', 'DH', 'EH', 'EH0', 'EH1', 'EH2', 'ER', 'ER0', 'ER1', 'ER2', 'EY', 'EY0', 'EY1', 'EY2', 'F', 'G', 'HH', 'I...
import re valid_symbols = [ 'AA', 'AA0', 'AA1', 'AA2', 'AE', 'AE0', 'AE1', 'AE2', 'AH', 'AH0', 'AH1', 'AH2', 'AO', 'AO0', 'AO1', 'AO2', 'AW', 'AW0', 'AW1', 'AW2', 'AY', 'AY0', 'AY1', 'AY2', 'B', 'CH', 'D', 'DH', 'EH', 'EH0', 'EH1', 'EH2', 'ER', 'ER0', 'ER1', 'ER2', 'EY', 'EY0', 'EY1', 'EY2', 'F', 'G', 'HH', 'I...
31,019
/home/hieuvd/dung_repo/raw/stars_02/Rayhane-mamah_Tacotron-2/Tacotron-2
/home/hieuvd/dung_repo/raw/stars_02/Rayhane-mamah_Tacotron-2/Tacotron-2/tacotron/utils/cmudict.py
33,34
16,39
lookup
CMUDict
35,39
34,39
class CMUDict: '''Thin wrapper around CMUDict data. http://www.speech.cs.cmu.edu/cgi-bin/cmudict''' def __init__(self, file_or_path, keep_ambiguous=True): if isinstance(file_or_path, str): with open(file_or_path, encoding='latin-1') as f: entries = _parse_cmudict(f) else: entries = _pars...
class CMUDict: '''Thin wrapper around CMUDict data. http://www.speech.cs.cmu.edu/cgi-bin/cmudict''' def __init__(self, file_or_path, keep_ambiguous=True): if isinstance(file_or_path, str): with open(file_or_path, encoding='latin-1') as f: entries = _parse_cmudict(f) else: entries = _pars...
return self._entries.get(word.upper())
'''Returns list of ARPAbet pronunciations of the given word.''' return self._entries.get(word.upper())
2
239
21
260
import re valid_symbols = [ 'AA', 'AA0', 'AA1', 'AA2', 'AE', 'AE0', 'AE1', 'AE2', 'AH', 'AH0', 'AH1', 'AH2', 'AO', 'AO0', 'AO1', 'AO2', 'AW', 'AW0', 'AW1', 'AW2', 'AY', 'AY0', 'AY1', 'AY2', 'B', 'CH', 'D', 'DH', 'EH', 'EH0', 'EH1', 'EH2', 'ER', 'ER0', 'ER1', 'ER2', 'EY', 'EY0', 'EY1', 'EY2', 'F', 'G', 'HH', 'I...
import re valid_symbols = [ 'AA', 'AA0', 'AA1', 'AA2', 'AE', 'AE0', 'AE1', 'AE2', 'AH', 'AH0', 'AH1', 'AH2', 'AO', 'AO0', 'AO1', 'AO2', 'AW', 'AW0', 'AW1', 'AW2', 'AY', 'AY0', 'AY1', 'AY2', 'B', 'CH', 'D', 'DH', 'EH', 'EH0', 'EH1', 'EH2', 'ER', 'ER0', 'ER1', 'ER2', 'EY', 'EY0', 'EY1', 'EY2', 'F', 'G', 'HH', 'I...