extended_data.primitives.transformations.numbers.notation

Helpers for converting numbers between common notations.

Module Contents

Functions

to_roman

Convert an integer between 1 and 3999 to Roman numerals.

from_roman

Convert a Roman numeral string to an integer.

to_ordinal

Convert an integer to an ordinal representation.

from_ordinal

Convert an ordinal string (numeric or word form) to an integer.

to_words

Expose :func:number_to_words via the notation namespace.

from_words

Expose :func:words_to_number via the notation namespace.

to_fraction

Convert a float to a fractional string representation.

from_fraction

Convert a fractional string (including mixed numbers) back to float.

Data

API

extended_data.primitives.transformations.numbers.notation._ROMAN_VALUES: Final[dict[str, int]] = None
extended_data.primitives.transformations.numbers.notation._MAX_ROMAN_VALUE: Final[int] = 3999
extended_data.primitives.transformations.numbers.notation.to_roman(number: int, *, upper: bool = True) str

Convert an integer between 1 and 3999 to Roman numerals.

extended_data.primitives.transformations.numbers.notation.from_roman(numeral: str) int

Convert a Roman numeral string to an integer.

extended_data.primitives.transformations.numbers.notation.to_ordinal(number: int, *, words: bool = False) str

Convert an integer to an ordinal representation.

extended_data.primitives.transformations.numbers.notation.from_ordinal(text: str) int

Convert an ordinal string (numeric or word form) to an integer.

extended_data.primitives.transformations.numbers.notation.to_words(number: float, *, capitalize: bool = False, conjunction: str = ' and ') str

Expose :func:number_to_words via the notation namespace.

extended_data.primitives.transformations.numbers.notation.from_words(text: str) float

Expose :func:words_to_number via the notation namespace.

extended_data.primitives.transformations.numbers.notation.to_fraction(number: float, *, mixed: bool = False, precision: int | None = None) str

Convert a float to a fractional string representation.

extended_data.primitives.transformations.numbers.notation.from_fraction(value: str) float

Convert a fractional string (including mixed numbers) back to float.