We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Scientific notation in QASM output causes export to other platform to fail
### Environment

- **Qiskit version**: {'qiskit-terra': '0.24.0', 'qiskit-aer': '0.12.0', 'qiskit-ignis': '0.7.1', 'qiskit-ibmq-provider': '0.20.2', 'qiskit': '0.43.0', 'qiskit-nature': None, 'qiskit-finance': None, 'qiskit-optimization': None, 'qiskit-machine-learning': None}
- **Python version**: 3.10.6
- **Operating system**: Linux Mint

### What is happening?

Exporting a circuit with small rotation gates through circuit.qasm() results in scientific notation being used. This causes issues when importing the QASM code into another quantum computing platform.

### How can we reproduce the issue?

```
from qiskit import QuantumCircuit
qc = QuantumCircuit(1)
qc.rx(0.00001, 0)
print(qc.qasm())
```
output:
```
OPENQASM 2.0;
include "qelib1.inc";
qreg q[1];
creg meas[1];
rx(1e-05) q[0];
barrier q[0];
measure q[0] -> meas[0];
```

### What should happen?

output:
```
OPENQASM 2.0;
include "qelib1.inc";
qreg q[1];
creg meas[1];
rx(0.00001) q[0];
barrier q[0];
measure q[0] -> meas[0];
```

### Any suggestions?

The conversion from float to string happens in `pi_check`. The call is `pi_check(0.00001, output="qasm", eps=1e-12)` and returns `'1e-05'`.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `qiskit/circuit/tools/pi_check.py`
Content:
```
1 # This code is part of Qiskit.
2 #
3 # (C) Copyright IBM 2017, 2019.
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 # pylint: disable=too-many-return-statements
13 
14 """Check if number close to values of PI
15 """
16 
17 import numpy as np
18 from qiskit.circuit.parameterexpression import ParameterExpression
19 from qiskit.exceptions import QiskitError
20 
21 MAX_FRAC = 16
22 N, D = np.meshgrid(np.arange(1, MAX_FRAC + 1), np.arange(1, MAX_FRAC + 1))
23 FRAC_MESH = N / D * np.pi
24 RECIP_MESH = N / D / np.pi
25 POW_LIST = np.pi ** np.arange(2, 5)
26 
27 
28 def pi_check(inpt, eps=1e-9, output="text", ndigits=None):
29     """Computes if a number is close to an integer
30     fraction or multiple of PI and returns the
31     corresponding string.
32 
33     Args:
34         inpt (float): Number to check.
35         eps (float): EPS to check against.
36         output (str): Options are 'text' (default),
37                       'latex', 'mpl', and 'qasm'.
38         ndigits (int or None): Number of digits to print
39                                if returning raw inpt.
40                                If `None` (default), Python's
41                                default float formatting is used.
42 
43     Returns:
44         str: string representation of output.
45 
46     Raises:
47         QiskitError: if output is not a valid option.
48     """
49     if isinstance(inpt, ParameterExpression):
50         param_str = str(inpt)
51         from sympy import sympify
52 
53         expr = sympify(inpt._symbol_expr)
54         syms = expr.atoms()
55         for sym in syms:
56             if not sym.is_number:
57                 continue
58             pi = pi_check(abs(float(sym)), eps=eps, output=output, ndigits=ndigits)
59             try:
60                 _ = float(pi)
61             except (ValueError, TypeError):
62                 from sympy import sstr
63 
64                 sym_str = sstr(abs(sym), full_prec=False)
65                 param_str = param_str.replace(sym_str, pi)
66         return param_str
67     elif isinstance(inpt, str):
68         return inpt
69 
70     def normalize(single_inpt):
71         if abs(single_inpt) < eps:
72             return "0"
73 
74         if output == "text":
75             pi = "π"
76         elif output == "qasm":
77             pi = "pi"
78         elif output == "latex":
79             pi = "\\pi"
80         elif output == "mpl":
81             pi = "$\\pi$"
82         else:
83             raise QiskitError("pi_check parameter output should be text, latex, mpl, or qasm.")
84 
85         neg_str = "-" if single_inpt < 0 else ""
86 
87         # First check is for whole multiples of pi
88         val = single_inpt / np.pi
89         if abs(val) >= 1 - eps:
90             if abs(abs(val) - abs(round(val))) < eps:
91                 val = int(abs(round(val)))
92                 if abs(val) == 1:
93                     str_out = f"{neg_str}{pi}"
94                 else:
95                     if output == "qasm":
96                         str_out = f"{neg_str}{val}*{pi}"
97                     else:
98                         str_out = f"{neg_str}{val}{pi}"
99                 return str_out
100 
101         # Second is a check for powers of pi
102         if abs(single_inpt) > np.pi:
103             power = np.where(abs(abs(single_inpt) - POW_LIST) < eps)
104             if power[0].shape[0]:
105                 if output == "qasm":
106                     if ndigits is None:
107                         str_out = "{}".format(single_inpt)
108                     else:
109                         str_out = "{:.{}g}".format(single_inpt, ndigits)
110                 elif output == "latex":
111                     str_out = f"{neg_str}{pi}^{power[0][0] + 2}"
112                 elif output == "mpl":
113                     str_out = f"{neg_str}{pi}$^{power[0][0] + 2}$"
114                 else:
115                     str_out = f"{neg_str}{pi}**{power[0][0] + 2}"
116                 return str_out
117 
118         # Third is a check for a number larger than MAX_FRAC * pi, not a
119         # multiple or power of pi, since no fractions will exceed MAX_FRAC * pi
120         if abs(single_inpt) >= (MAX_FRAC * np.pi):
121             if ndigits is None:
122                 str_out = "{}".format(single_inpt)
123             else:
124                 str_out = "{:.{}g}".format(single_inpt, ndigits)
125             return str_out
126 
127         # Fourth check is for fractions for 1*pi in the numer and any
128         # number in the denom.
129         val = np.pi / single_inpt
130         if abs(abs(val) - abs(round(val))) < eps:
131             val = int(abs(round(val)))
132             if output == "latex":
133                 str_out = f"\\frac{{{neg_str}{pi}}}{{{val}}}"
134             else:
135                 str_out = f"{neg_str}{pi}/{val}"
136             return str_out
137 
138         # Fifth check is for fractions where the numer > 1*pi and numer
139         # is up to MAX_FRAC*pi and denom is up to MAX_FRAC and all
140         # fractions are reduced. Ex. 15pi/16, 2pi/5, 15pi/2, 16pi/9.
141         frac = np.where(np.abs(abs(single_inpt) - FRAC_MESH) < eps)
142         if frac[0].shape[0]:
143             numer = int(frac[1][0]) + 1
144             denom = int(frac[0][0]) + 1
145             if output == "latex":
146                 str_out = f"\\frac{{{neg_str}{numer}{pi}}}{{{denom}}}"
147             elif output == "qasm":
148                 str_out = f"{neg_str}{numer}*{pi}/{denom}"
149             else:
150                 str_out = f"{neg_str}{numer}{pi}/{denom}"
151             return str_out
152 
153         # Sixth check is for fractions where the numer > 1 and numer
154         # is up to MAX_FRAC and denom is up to MAX_FRAC*pi and all
155         # fractions are reduced. Ex. 15/16pi, 2/5pi, 15/2pi, 16/9pi
156         frac = np.where(np.abs(abs(single_inpt) - RECIP_MESH) < eps)
157         if frac[0].shape[0]:
158             numer = int(frac[1][0]) + 1
159             denom = int(frac[0][0]) + 1
160             if denom == 1 and output != "qasm":
161                 denom = ""
162             if output == "latex":
163                 str_out = f"\\frac{{{neg_str}{numer}}}{{{denom}{pi}}}"
164             elif output == "qasm":
165                 str_out = f"{neg_str}{numer}/({denom}*{pi})"
166             else:
167                 str_out = f"{neg_str}{numer}/{denom}{pi}"
168             return str_out
169 
170         # Nothing found
171         if ndigits is None:
172             str_out = "{}".format(single_inpt)
173         else:
174             str_out = "{:.{}g}".format(single_inpt, ndigits)
175         return str_out
176 
177     complex_inpt = complex(inpt)
178     real, imag = map(normalize, [complex_inpt.real, complex_inpt.imag])
179 
180     jstr = "\\jmath" if output == "latex" else "j"
181     if real == "0" and imag != "0":
182         str_out = imag + jstr
183     elif real != "0" and imag != "0":
184         op_str = "+"
185         # Remove + if imag negative except for latex fractions
186         if complex_inpt.imag < 0 and (output != "latex" or "\\frac" not in imag):
187             op_str = ""
188         str_out = f"{real}{op_str}{imag}{jstr}"
189     else:
190         str_out = real
191     return str_out
192
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/qiskit/circuit/tools/pi_check.py b/qiskit/circuit/tools/pi_check.py
--- a/qiskit/circuit/tools/pi_check.py
+++ b/qiskit/circuit/tools/pi_check.py
@@ -167,12 +167,11 @@
                 str_out = f"{neg_str}{numer}/{denom}{pi}"
             return str_out
 
-        # Nothing found
-        if ndigits is None:
-            str_out = "{}".format(single_inpt)
-        else:
-            str_out = "{:.{}g}".format(single_inpt, ndigits)
-        return str_out
+        # Nothing found.  The '#' forces a decimal point to be included, which OQ2 needs, but other
+        # formats don't really.
+        if output == "qasm":
+            return f"{single_inpt:#}" if ndigits is None else f"{single_inpt:#.{ndigits}g}"
+        return f"{single_inpt}" if ndigits is None else f"{single_inpt:.{ndigits}g}"
 
     complex_inpt = complex(inpt)
     real, imag = map(normalize, [complex_inpt.real, complex_inpt.imag])

{"golden_diff": "diff --git a/qiskit/circuit/tools/pi_check.py b/qiskit/circuit/tools/pi_check.py\n--- a/qiskit/circuit/tools/pi_check.py\n+++ b/qiskit/circuit/tools/pi_check.py\n@@ -167,12 +167,11 @@\n                 str_out = f\"{neg_str}{numer}/{denom}{pi}\"\n             return str_out\n \n-        # Nothing found\n-        if ndigits is None:\n-            str_out = \"{}\".format(single_inpt)\n-        else:\n-            str_out = \"{:.{}g}\".format(single_inpt, ndigits)\n-        return str_out\n+        # Nothing found.  The '#' forces a decimal point to be included, which OQ2 needs, but other\n+        # formats don't really.\n+        if output == \"qasm\":\n+            return f\"{single_inpt:#}\" if ndigits is None else f\"{single_inpt:#.{ndigits}g}\"\n+        return f\"{single_inpt}\" if ndigits is None else f\"{single_inpt:.{ndigits}g}\"\n \n     complex_inpt = complex(inpt)\n     real, imag = map(normalize, [complex_inpt.real, complex_inpt.imag])\n", "issue": "Scientific notation in QASM output causes export to other platform to fail\n### Environment\n\n- **Qiskit version**: {'qiskit-terra': '0.24.0', 'qiskit-aer': '0.12.0', 'qiskit-ignis': '0.7.1', 'qiskit-ibmq-provider': '0.20.2', 'qiskit': '0.43.0', 'qiskit-nature': None, 'qiskit-finance': None, 'qiskit-optimization': None, 'qiskit-machine-learning': None}\r\n- **Python version**: 3.10.6\r\n- **Operating system**: Linux Mint\n\n### What is happening?\n\nExporting a circuit with small rotation gates through circuit.qasm() results in scientific notation being used. This causes issues when importing the QASM code into another quantum computing platform.\n\n### How can we reproduce the issue?\n\n```\r\nfrom qiskit import QuantumCircuit\r\nqc = QuantumCircuit(1)\r\nqc.rx(0.00001, 0)\r\nprint(qc.qasm())\r\n```\r\noutput:\r\n```\r\nOPENQASM 2.0;\r\ninclude \"qelib1.inc\";\r\nqreg q[1];\r\ncreg meas[1];\r\nrx(1e-05) q[0];\r\nbarrier q[0];\r\nmeasure q[0] -> meas[0];\r\n```\n\n### What should happen?\n\noutput:\r\n```\r\nOPENQASM 2.0;\r\ninclude \"qelib1.inc\";\r\nqreg q[1];\r\ncreg meas[1];\r\nrx(0.00001) q[0];\r\nbarrier q[0];\r\nmeasure q[0] -> meas[0];\r\n```\n\n### Any suggestions?\n\nThe conversion from float to string happens in `pi_check`. The call is `pi_check(0.00001, output=\"qasm\", eps=1e-12)` and returns `'1e-05'`.\n", "before_files": [{"content": "# This code is part of Qiskit.\n#\n# (C) Copyright IBM 2017, 2019.\n#\n# This code is licensed under the Apache License, Version 2.0. You may\n# obtain a copy of this license in the LICENSE.txt file in the root directory\n# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.\n#\n# Any modifications or derivative works of this code must retain this\n# copyright notice, and modified files need to carry a notice indicating\n# that they have been altered from the originals.\n# pylint: disable=too-many-return-statements\n\n\"\"\"Check if number close to values of PI\n\"\"\"\n\nimport numpy as np\nfrom qiskit.circuit.parameterexpression import ParameterExpression\nfrom qiskit.exceptions import QiskitError\n\nMAX_FRAC = 16\nN, D = np.meshgrid(np.arange(1, MAX_FRAC + 1), np.arange(1, MAX_FRAC + 1))\nFRAC_MESH = N / D * np.pi\nRECIP_MESH = N / D / np.pi\nPOW_LIST = np.pi ** np.arange(2, 5)\n\n\ndef pi_check(inpt, eps=1e-9, output=\"text\", ndigits=None):\n    \"\"\"Computes if a number is close to an integer\n    fraction or multiple of PI and returns the\n    corresponding string.\n\n    Args:\n        inpt (float): Number to check.\n        eps (float): EPS to check against.\n        output (str): Options are 'text' (default),\n                      'latex', 'mpl', and 'qasm'.\n        ndigits (int or None): Number of digits to print\n                               if returning raw inpt.\n                               If `None` (default), Python's\n                               default float formatting is used.\n\n    Returns:\n        str: string representation of output.\n\n    Raises:\n        QiskitError: if output is not a valid option.\n    \"\"\"\n    if isinstance(inpt, ParameterExpression):\n        param_str = str(inpt)\n        from sympy import sympify\n\n        expr = sympify(inpt._symbol_expr)\n        syms = expr.atoms()\n        for sym in syms:\n            if not sym.is_number:\n                continue\n            pi = pi_check(abs(float(sym)), eps=eps, output=output, ndigits=ndigits)\n            try:\n                _ = float(pi)\n            except (ValueError, TypeError):\n                from sympy import sstr\n\n                sym_str = sstr(abs(sym), full_prec=False)\n                param_str = param_str.replace(sym_str, pi)\n        return param_str\n    elif isinstance(inpt, str):\n        return inpt\n\n    def normalize(single_inpt):\n        if abs(single_inpt) < eps:\n            return \"0\"\n\n        if output == \"text\":\n            pi = \"\u03c0\"\n        elif output == \"qasm\":\n            pi = \"pi\"\n        elif output == \"latex\":\n            pi = \"\\\\pi\"\n        elif output == \"mpl\":\n            pi = \"$\\\\pi$\"\n        else:\n            raise QiskitError(\"pi_check parameter output should be text, latex, mpl, or qasm.\")\n\n        neg_str = \"-\" if single_inpt < 0 else \"\"\n\n        # First check is for whole multiples of pi\n        val = single_inpt / np.pi\n        if abs(val) >= 1 - eps:\n            if abs(abs(val) - abs(round(val))) < eps:\n                val = int(abs(round(val)))\n                if abs(val) == 1:\n                    str_out = f\"{neg_str}{pi}\"\n                else:\n                    if output == \"qasm\":\n                        str_out = f\"{neg_str}{val}*{pi}\"\n                    else:\n                        str_out = f\"{neg_str}{val}{pi}\"\n                return str_out\n\n        # Second is a check for powers of pi\n        if abs(single_inpt) > np.pi:\n            power = np.where(abs(abs(single_inpt) - POW_LIST) < eps)\n            if power[0].shape[0]:\n                if output == \"qasm\":\n                    if ndigits is None:\n                        str_out = \"{}\".format(single_inpt)\n                    else:\n                        str_out = \"{:.{}g}\".format(single_inpt, ndigits)\n                elif output == \"latex\":\n                    str_out = f\"{neg_str}{pi}^{power[0][0] + 2}\"\n                elif output == \"mpl\":\n                    str_out = f\"{neg_str}{pi}$^{power[0][0] + 2}$\"\n                else:\n                    str_out = f\"{neg_str}{pi}**{power[0][0] + 2}\"\n                return str_out\n\n        # Third is a check for a number larger than MAX_FRAC * pi, not a\n        # multiple or power of pi, since no fractions will exceed MAX_FRAC * pi\n        if abs(single_inpt) >= (MAX_FRAC * np.pi):\n            if ndigits is None:\n                str_out = \"{}\".format(single_inpt)\n            else:\n                str_out = \"{:.{}g}\".format(single_inpt, ndigits)\n            return str_out\n\n        # Fourth check is for fractions for 1*pi in the numer and any\n        # number in the denom.\n        val = np.pi / single_inpt\n        if abs(abs(val) - abs(round(val))) < eps:\n            val = int(abs(round(val)))\n            if output == \"latex\":\n                str_out = f\"\\\\frac{{{neg_str}{pi}}}{{{val}}}\"\n            else:\n                str_out = f\"{neg_str}{pi}/{val}\"\n            return str_out\n\n        # Fifth check is for fractions where the numer > 1*pi and numer\n        # is up to MAX_FRAC*pi and denom is up to MAX_FRAC and all\n        # fractions are reduced. Ex. 15pi/16, 2pi/5, 15pi/2, 16pi/9.\n        frac = np.where(np.abs(abs(single_inpt) - FRAC_MESH) < eps)\n        if frac[0].shape[0]:\n            numer = int(frac[1][0]) + 1\n            denom = int(frac[0][0]) + 1\n            if output == \"latex\":\n                str_out = f\"\\\\frac{{{neg_str}{numer}{pi}}}{{{denom}}}\"\n            elif output == \"qasm\":\n                str_out = f\"{neg_str}{numer}*{pi}/{denom}\"\n            else:\n                str_out = f\"{neg_str}{numer}{pi}/{denom}\"\n            return str_out\n\n        # Sixth check is for fractions where the numer > 1 and numer\n        # is up to MAX_FRAC and denom is up to MAX_FRAC*pi and all\n        # fractions are reduced. Ex. 15/16pi, 2/5pi, 15/2pi, 16/9pi\n        frac = np.where(np.abs(abs(single_inpt) - RECIP_MESH) < eps)\n        if frac[0].shape[0]:\n            numer = int(frac[1][0]) + 1\n            denom = int(frac[0][0]) + 1\n            if denom == 1 and output != \"qasm\":\n                denom = \"\"\n            if output == \"latex\":\n                str_out = f\"\\\\frac{{{neg_str}{numer}}}{{{denom}{pi}}}\"\n            elif output == \"qasm\":\n                str_out = f\"{neg_str}{numer}/({denom}*{pi})\"\n            else:\n                str_out = f\"{neg_str}{numer}/{denom}{pi}\"\n            return str_out\n\n        # Nothing found\n        if ndigits is None:\n            str_out = \"{}\".format(single_inpt)\n        else:\n            str_out = \"{:.{}g}\".format(single_inpt, ndigits)\n        return str_out\n\n    complex_inpt = complex(inpt)\n    real, imag = map(normalize, [complex_inpt.real, complex_inpt.imag])\n\n    jstr = \"\\\\jmath\" if output == \"latex\" else \"j\"\n    if real == \"0\" and imag != \"0\":\n        str_out = imag + jstr\n    elif real != \"0\" and imag != \"0\":\n        op_str = \"+\"\n        # Remove + if imag negative except for latex fractions\n        if complex_inpt.imag < 0 and (output != \"latex\" or \"\\\\frac\" not in imag):\n            op_str = \"\"\n        str_out = f\"{real}{op_str}{imag}{jstr}\"\n    else:\n        str_out = real\n    return str_out\n", "path": "qiskit/circuit/tools/pi_check.py"}], "after_files": [{"content": "# This code is part of Qiskit.\n#\n# (C) Copyright IBM 2017, 2019.\n#\n# This code is licensed under the Apache License, Version 2.0. You may\n# obtain a copy of this license in the LICENSE.txt file in the root directory\n# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.\n#\n# Any modifications or derivative works of this code must retain this\n# copyright notice, and modified files need to carry a notice indicating\n# that they have been altered from the originals.\n# pylint: disable=too-many-return-statements\n\n\"\"\"Check if number close to values of PI\n\"\"\"\n\nimport numpy as np\nfrom qiskit.circuit.parameterexpression import ParameterExpression\nfrom qiskit.exceptions import QiskitError\n\nMAX_FRAC = 16\nN, D = np.meshgrid(np.arange(1, MAX_FRAC + 1), np.arange(1, MAX_FRAC + 1))\nFRAC_MESH = N / D * np.pi\nRECIP_MESH = N / D / np.pi\nPOW_LIST = np.pi ** np.arange(2, 5)\n\n\ndef pi_check(inpt, eps=1e-9, output=\"text\", ndigits=None):\n    \"\"\"Computes if a number is close to an integer\n    fraction or multiple of PI and returns the\n    corresponding string.\n\n    Args:\n        inpt (float): Number to check.\n        eps (float): EPS to check against.\n        output (str): Options are 'text' (default),\n                      'latex', 'mpl', and 'qasm'.\n        ndigits (int or None): Number of digits to print\n                               if returning raw inpt.\n                               If `None` (default), Python's\n                               default float formatting is used.\n\n    Returns:\n        str: string representation of output.\n\n    Raises:\n        QiskitError: if output is not a valid option.\n    \"\"\"\n    if isinstance(inpt, ParameterExpression):\n        param_str = str(inpt)\n        from sympy import sympify\n\n        expr = sympify(inpt._symbol_expr)\n        syms = expr.atoms()\n        for sym in syms:\n            if not sym.is_number:\n                continue\n            pi = pi_check(abs(float(sym)), eps=eps, output=output, ndigits=ndigits)\n            try:\n                _ = float(pi)\n            except (ValueError, TypeError):\n                from sympy import sstr\n\n                sym_str = sstr(abs(sym), full_prec=False)\n                param_str = param_str.replace(sym_str, pi)\n        return param_str\n    elif isinstance(inpt, str):\n        return inpt\n\n    def normalize(single_inpt):\n        if abs(single_inpt) < eps:\n            return \"0\"\n\n        if output == \"text\":\n            pi = \"\u03c0\"\n        elif output == \"qasm\":\n            pi = \"pi\"\n        elif output == \"latex\":\n            pi = \"\\\\pi\"\n        elif output == \"mpl\":\n            pi = \"$\\\\pi$\"\n        else:\n            raise QiskitError(\"pi_check parameter output should be text, latex, mpl, or qasm.\")\n\n        neg_str = \"-\" if single_inpt < 0 else \"\"\n\n        # First check is for whole multiples of pi\n        val = single_inpt / np.pi\n        if abs(val) >= 1 - eps:\n            if abs(abs(val) - abs(round(val))) < eps:\n                val = int(abs(round(val)))\n                if abs(val) == 1:\n                    str_out = f\"{neg_str}{pi}\"\n                else:\n                    if output == \"qasm\":\n                        str_out = f\"{neg_str}{val}*{pi}\"\n                    else:\n                        str_out = f\"{neg_str}{val}{pi}\"\n                return str_out\n\n        # Second is a check for powers of pi\n        if abs(single_inpt) > np.pi:\n            power = np.where(abs(abs(single_inpt) - POW_LIST) < eps)\n            if power[0].shape[0]:\n                if output == \"qasm\":\n                    if ndigits is None:\n                        str_out = \"{}\".format(single_inpt)\n                    else:\n                        str_out = \"{:.{}g}\".format(single_inpt, ndigits)\n                elif output == \"latex\":\n                    str_out = f\"{neg_str}{pi}^{power[0][0] + 2}\"\n                elif output == \"mpl\":\n                    str_out = f\"{neg_str}{pi}$^{power[0][0] + 2}$\"\n                else:\n                    str_out = f\"{neg_str}{pi}**{power[0][0] + 2}\"\n                return str_out\n\n        # Third is a check for a number larger than MAX_FRAC * pi, not a\n        # multiple or power of pi, since no fractions will exceed MAX_FRAC * pi\n        if abs(single_inpt) >= (MAX_FRAC * np.pi):\n            if ndigits is None:\n                str_out = \"{}\".format(single_inpt)\n            else:\n                str_out = \"{:.{}g}\".format(single_inpt, ndigits)\n            return str_out\n\n        # Fourth check is for fractions for 1*pi in the numer and any\n        # number in the denom.\n        val = np.pi / single_inpt\n        if abs(abs(val) - abs(round(val))) < eps:\n            val = int(abs(round(val)))\n            if output == \"latex\":\n                str_out = f\"\\\\frac{{{neg_str}{pi}}}{{{val}}}\"\n            else:\n                str_out = f\"{neg_str}{pi}/{val}\"\n            return str_out\n\n        # Fifth check is for fractions where the numer > 1*pi and numer\n        # is up to MAX_FRAC*pi and denom is up to MAX_FRAC and all\n        # fractions are reduced. Ex. 15pi/16, 2pi/5, 15pi/2, 16pi/9.\n        frac = np.where(np.abs(abs(single_inpt) - FRAC_MESH) < eps)\n        if frac[0].shape[0]:\n            numer = int(frac[1][0]) + 1\n            denom = int(frac[0][0]) + 1\n            if output == \"latex\":\n                str_out = f\"\\\\frac{{{neg_str}{numer}{pi}}}{{{denom}}}\"\n            elif output == \"qasm\":\n                str_out = f\"{neg_str}{numer}*{pi}/{denom}\"\n            else:\n                str_out = f\"{neg_str}{numer}{pi}/{denom}\"\n            return str_out\n\n        # Sixth check is for fractions where the numer > 1 and numer\n        # is up to MAX_FRAC and denom is up to MAX_FRAC*pi and all\n        # fractions are reduced. Ex. 15/16pi, 2/5pi, 15/2pi, 16/9pi\n        frac = np.where(np.abs(abs(single_inpt) - RECIP_MESH) < eps)\n        if frac[0].shape[0]:\n            numer = int(frac[1][0]) + 1\n            denom = int(frac[0][0]) + 1\n            if denom == 1 and output != \"qasm\":\n                denom = \"\"\n            if output == \"latex\":\n                str_out = f\"\\\\frac{{{neg_str}{numer}}}{{{denom}{pi}}}\"\n            elif output == \"qasm\":\n                str_out = f\"{neg_str}{numer}/({denom}*{pi})\"\n            else:\n                str_out = f\"{neg_str}{numer}/{denom}{pi}\"\n            return str_out\n\n        # Nothing found.  The '#' forces a decimal point to be included, which OQ2 needs, but other\n        # formats don't really.\n        if output == \"qasm\":\n            return f\"{single_inpt:#}\" if ndigits is None else f\"{single_inpt:#.{ndigits}g}\"\n        return f\"{single_inpt}\" if ndigits is None else f\"{single_inpt:.{ndigits}g}\"\n\n    complex_inpt = complex(inpt)\n    real, imag = map(normalize, [complex_inpt.real, complex_inpt.imag])\n\n    jstr = \"\\\\jmath\" if output == \"latex\" else \"j\"\n    if real == \"0\" and imag != \"0\":\n        str_out = imag + jstr\n    elif real != \"0\" and imag != \"0\":\n        op_str = \"+\"\n        # Remove + if imag negative except for latex fractions\n        if complex_inpt.imag < 0 and (output != \"latex\" or \"\\\\frac\" not in imag):\n            op_str = \"\"\n        str_out = f\"{real}{op_str}{imag}{jstr}\"\n    else:\n        str_out = real\n    return str_out\n", "path": "qiskit/circuit/tools/pi_check.py"}]}