(raw_value: str)
| 172 | |
| 173 | |
| 174 | def format_lambda_value(raw_value: str) -> str: |
| 175 | try: |
| 176 | value = float(raw_value) |
| 177 | except (ValueError, TypeError): |
| 178 | try: |
| 179 | value = float(Decimal(raw_value)) |
| 180 | except (InvalidOperation, ValueError): |
| 181 | return latex_escape(raw_value) |
| 182 | |
| 183 | if value == 0.0: |
| 184 | return "0" |
| 185 | |
| 186 | exponent = int(math.floor(math.log10(abs(value)))) |
| 187 | mantissa = value / (10 ** exponent) |
| 188 | |
| 189 | if math.isclose(mantissa, round(mantissa)): |
| 190 | mantissa_str = str(int(round(mantissa))) |
| 191 | else: |
| 192 | mantissa_str = f"{mantissa:.2f}".rstrip("0").rstrip(".") |
| 193 | |
| 194 | return f"{mantissa_str}{{\\times}}10^{{{exponent}}}" |
| 195 | |
| 196 | |
| 197 | def format_display_name(method: str, normalized_variant: Optional[str]) -> str: |
no test coverage detected