• 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

35.71
/waveforms/qlisp/qasm/node/prefix.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 prefix expression."""
9✔
14

15
import warnings
9✔
16

17
from .node import Node
9✔
18

19

20
class Prefix(Node):
9✔
21
    """Node for an OPENQASM prefix expression.
22
    children[0] is a unary operator node.
23
    children[1] is an expression node.
24
    """
25

26
    def __init__(self, children):
9✔
27
        """Create the prefix node."""
28
        super().__init__('prefix', children, None)
9✔
29

30
    def qasm(self, prec=None):
9✔
31
        """Return the corresponding OPENQASM string."""
32
        if prec is not None:
×
33
            warnings.warn('Parameter \'Prefix.qasm(..., prec)\' is no longer used and is being '
×
34
                          'deprecated.', DeprecationWarning, 2)
35
        return self.children[0].value + "(" + self.children[1].qasm() + ")"
×
36

37
    def latex(self, prec=None, nested_scope=None):
9✔
38
        """Return the corresponding math mode latex string."""
39
        if prec is not None:
×
40
            warnings.warn('Parameter \'Prefix.latex(..., prec)\' is no longer used and is being '
×
41
                          'deprecated.', DeprecationWarning, 2)
42
        if nested_scope is not None:
×
43
            warnings.warn('Parameter \'Prefix.latex(..., nested_scope)\' is no longer used and is '
×
44
                          'being deprecated.', DeprecationWarning, 2)
45
        try:
×
46
            from pylatexenc.latexencode import utf8tolatex
×
47
        except ImportError:
×
48
            raise ImportError("To export latex from qasm "
×
49
                              "pylatexenc needs to be installed. Run "
50
                              "'pip install pylatexenc' before using this "
51
                              "method.")
52
        return utf8tolatex(self.sym())
×
53

54
    def real(self, nested_scope=None):
9✔
55
        """Return the correspond floating point number."""
56
        operation = self.children[0].operation()
×
57
        expr = self.children[1].real(nested_scope)
×
58
        return operation(expr)
×
59

60
    def sym(self, nested_scope=None):
9✔
61
        """Return the correspond symbolic number."""
62
        operation = self.children[0].operation()
×
63
        expr = self.children[1].sym(nested_scope)
×
64
        return operation(expr)
×
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