• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

feihoo87 / waveforms / 6534953321

16 Oct 2023 02:19PM UTC coverage: 35.674% (-22.7%) from 58.421%
6534953321

push

github

feihoo87
fix Coveralls

5913 of 16575 relevant lines covered (35.67%)

3.21 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.42
/waveforms/qlisp/qasm/node/creg.py
1
# This code is part of Qiskit.
2
#
3
# (C) Copyright IBM 2017.
4
#
5
# This code is licensed under the Apache License, Version 2.0. You may
6
# obtain a copy of this license in the LICENSE.txt file in the root directory
7
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
8
#
9
# Any modifications or derivative works of this code must retain this
10
# copyright notice, and modified files need to carry a notice indicating
11
# that they have been altered from the originals.
12

13
"""Node for an OPENQASM creg statement."""
9✔
14
import warnings
9✔
15

16
from .node import Node
9✔
17

18

19
class Creg(Node):
9✔
20
    """Node for an OPENQASM creg statement.
21
    children[0] is an indexedid node.
22
    """
23

24
    def __init__(self, children):
9✔
25
        """Create the creg node."""
26
        super().__init__('creg', children, None)
9✔
27
        # This is the indexed id, the full "id[n]" object
28
        self.id = children[0]  # pylint: disable=invalid-name
9✔
29
        # Name of the creg
30
        self.name = self.id.name
9✔
31
        # Source line number
32
        self.line = self.id.line
9✔
33
        # Source file name
34
        self.file = self.id.file
9✔
35
        # Size of the register
36
        self.index = self.id.index
9✔
37

38
    def to_string(self, indent):
9✔
39
        """Print the node data, with indent."""
40
        ind = indent * ' '
×
41
        print(ind, 'creg')
×
42
        self.children[0].to_string(indent + 3)
×
43

44
    def qasm(self, prec=None):
9✔
45
        """Return the corresponding OPENQASM string."""
46
        if prec is not None:
×
47
            warnings.warn('Parameter \'Creg.qasm(..., prec)\' is no longer used and is being '
×
48
                          'deprecated.', DeprecationWarning, 2)
49
        return "creg " + self.id.qasm() + ";"
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc