polymerist.maths.fractions.ratios ================================= .. py:module:: polymerist.maths.fractions.ratios .. autoapi-nested-parse:: For representing rational numbers, and more general ratios Attributes ---------- .. autoapisummary:: polymerist.maths.fractions.ratios.N Classes ------- .. autoapisummary:: polymerist.maths.fractions.ratios.Ratio polymerist.maths.fractions.ratios.Rational Functions --------- .. autoapisummary:: polymerist.maths.fractions.ratios.sgnmag Module Contents --------------- .. py:data:: N .. py:function:: sgnmag(num: N) -> tuple[bool, N] Returns the sign and magnitude of a numeric-like value .. py:class:: Ratio For representing fractional ratios between two objects .. py:attribute:: num :type: Any .. py:attribute:: denom :type: Any .. py:method:: to_latex() -> str Return latex-compatible string which represent fraction .. py:property:: reciprocal :type: Ratio Return the reciprocal of a ration .. py:class:: Rational Bases: :py:obj:`Ratio` For representing ratios of integers .. py:attribute:: num :type: int .. py:attribute:: denom :type: int .. py:attribute:: autoreduce :type: ClassVar[bool] :value: False .. py:method:: reduce() -> None Reduce numerator and denominator by greatest common factor .. py:attribute:: simplify .. py:property:: reduced :type: Rational Return reduced Rational equivalent to the current rational (does not modify in-place) .. py:attribute:: simplifed .. py:method:: as_proper() -> tuple[int, Rational] Returns the integer and proper fractional component of a ratio