catacomb/__init__.py: Prepare rational classes for upcoming changes.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 23 Nov 2019 23:39:21 +0000 (23:39 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 11 Apr 2020 11:49:31 +0000 (12:49 +0100)
commit8d299320103cc6803e76d9053b11b10313a324e2
tree3b5cc335f4dc04c30f4433bb4cd482d2641926bf
parent5b29dfaf13a37a2454103cf79db50c9dc8bb484d
catacomb/__init__.py: Prepare rational classes for upcoming changes.

In the near future, we won't be able to guarantee that all rings allow
implicit conversions of (integer) 0 and 1 to the additive and
multiplicative ring identities, so:

  * define `ZERO' and `ONE' class attributes on the concrete classes to
    hold the respective ring identities;

  * make the `_split_rat' function into a private method of the
    `BaseRat' class and adjust callers to match;

  * compare against `ZERO' to detect an exact element of the base ring;
    and

  * return `ONE' as the implicit denominator for a base-ring element or
    foreign object to be converted.

No functional change.
catacomb/__init__.py