File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99from .i18n import _ngettext_noop as NS_
1010from .i18n import _pgettext as P_
1111
12+
13+ TYPE_CHECKING = False
14+ if TYPE_CHECKING :
15+ from typing import TypeAlias
16+
17+ # This type can be better defined by typing.SupportsFloat
18+ # but that's a Python 3.8 only typing option.
19+ NumberOrString : TypeAlias = float | str
20+
21+
1222_SUPERSCRIPT_MAP = {
1323 "0" : "⁰" ,
1424 "1" : "¹" ,
2333 "-" : "⁻" ,
2434}
2535
26- TYPE_CHECKING = False
27- if TYPE_CHECKING :
28- from typing import TypeAlias
29-
30- # This type can be better defined by typing.SupportsFloat
31- # but that's a Python 3.8 only typing option.
32- NumberOrString : TypeAlias = float | str
33-
3436
3537def _format_not_finite (value : float ) -> str :
3638 """Utility function to handle infinite and nan cases."""
@@ -442,8 +444,8 @@ def scientific(value: NumberOrString, precision: int = 2) -> str:
442444 import re
443445
444446 part2 = re .sub (r"^\+?(\-?)0*(.+)$" , r"\1\2" , part2 )
447+ return part1 + " x 10" + "" .join ([_SUPERSCRIPT_MAP [char ] for char in part2 ])
445448
446- return part1 + " x 10" + "" .join (_SUPERSCRIPT_MAP [char ] for char in part2 )
447449
448450
449451def clamp (
You can’t perform that action at this time.
0 commit comments