piel.visual.table.symbol#
Attributes#
Functions#
|
Converts a number to the closest fraction of π in LaTeX format if possible. |
|
Converts each element in a tuple of numbers to a fraction of π in LaTeX format if possible. |
Module Contents#
- logger#
- convert_to_pi_fraction(value: float | int | str, max_denominator: int = 100) str[source]#
Converts a number to the closest fraction of π in LaTeX format if possible.
- Parameters:
value (Union[float, int, str]) – The input number or string representing a number.
max_denominator (int) – The maximum denominator for the fraction (default is 100).
- Returns:
A LaTeX string representation of the number as a fraction of π if possible.
- Return type:
str
Examples
>>> closest_pi_fraction(3.14159) '\pi'
>>> closest_pi_fraction(1.0472) '\frac{\pi}{3}'
>>> closest_pi_fraction(0.523599) '\frac{\pi}{6}'
>>> closest_pi_fraction(1) '1'
- convert_tuple_to_pi_fractions(values: tuple[int | float | str, Ellipsis]) tuple[str, Ellipsis][source]#
Converts each element in a tuple of numbers to a fraction of π in LaTeX format if possible.
- Parameters:
values (Tuple[Union[int, float, str], ...]) – A tuple of numbers or strings representing numbers.
- Returns:
A tuple of LaTeX string representations for each number as a fraction of π if possible.
- Return type:
Tuple[str, …]
Examples
>>> convert_tuple_to_pi_fractions((3.14159, 1.5708, 1)) ('\pi', '\frac{\pi}{2}', '1')
>>> convert_tuple_to_pi_fractions((0.785398, 0.523599, 0)) ('\frac{\pi}{4}', '\frac{\pi}{6}', '0')