• 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

53.85
/waveforms/qlisp/qasm/node/intnode.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 integer."""
9✔
14

15
import warnings
9✔
16

17
from .node import Node
9✔
18

19

20
class Int(Node):
9✔
21
    """Node for an OPENQASM integer.
22
    This node has no children. The data is in the value field.
23
    """
24

25
    def __init__(self, id):
9✔
26
        """Create the integer node."""
27
        # pylint: disable=redefined-builtin
28
        super().__init__("int", None, None)
9✔
29
        self.value = id
9✔
30

31
    def to_string(self, indent):
9✔
32
        """Print with indent."""
33
        ind = indent * ' '
×
34
        print(ind, 'int', self.value)
×
35

36
    def qasm(self, prec=None):
9✔
37
        """Return the corresponding OPENQASM string."""
38
        if prec is not None:
×
39
            warnings.warn('Parameter \'Int.qasm(..., prec)\' is no longer used and is being '
×
40
                          'deprecated.', DeprecationWarning, 2)
41
        return "%d" % self.value
×
42

43
    def latex(self, prec=None, nested_scope=None):
9✔
44
        """Return the corresponding math mode latex string."""
45
        if prec is not None:
×
46
            warnings.warn('Parameter \'Int.latex(..., prec)\' is no longer used and is being '
×
47
                          'deprecated.', DeprecationWarning, 2)
48
        if nested_scope is not None:
×
49
            warnings.warn('Parameter \'Int.latex(..., nested_scope)\' is no longer used and is '
×
50
                          'being deprecated.', DeprecationWarning, 2)
51
        return "%d" % self.value
×
52

53
    def sym(self, nested_scope=None):
9✔
54
        """Return the correspond symbolic number."""
55
        del nested_scope
×
56
        return float(self.value)
×
57

58
    def real(self, nested_scope=None):
9✔
59
        """Return the correspond floating point number."""
60
        del nested_scope  # ignored
9✔
61
        return float(self.value)
9✔
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

© 2025 Coveralls, Inc