From: Mark Wooding Date: Mon, 1 May 2017 00:38:30 +0000 (+0100) Subject: catacomb/__init__.py: Print group elements properly. X-Git-Tag: 1.2.0~28 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/catacomb-python/commitdiff_plain/d7012c2b527e1a079c78ec4c383083ac4f0eb850 catacomb/__init__.py: Print group elements properly. Slightly grim: add a method to group objects to export their elements as some useful type, and then call that from the element print function. --- diff --git a/catacomb/__init__.py b/catacomb/__init__.py index bc050be..28b4f85 100644 --- a/catacomb/__init__.py +++ b/catacomb/__init__.py @@ -589,6 +589,7 @@ class _tmp: h ^= 2*hash(info.r) & 0xffffffff h ^= 5*hash(info.g) & 0xffffffff return h + def _get_geval(me, x): return MP(x) _augment(PrimeGroup, _tmp) class _tmp: @@ -599,16 +600,19 @@ class _tmp: h ^= 2*hash(info.r) & 0xffffffff h ^= 5*hash(info.g) & 0xffffffff return h + def _get_geval(me, x): return GF(x) _augment(BinGroup, _tmp) class _tmp: def __hash__(me): return 0x0ec23dab ^ hash(me.info) + def _get_geval(me, x): return x.toec() _augment(ECGroup, _tmp) class _tmp: def __repr__(me): return '%r(%r)' % (me.group, str(me)) - _repr_pretty_ = _pp_str + def _repr_pretty_(me, pp, cyclep): + pp.pretty(type(me)._get_geval(me)) _augment(GE, _tmp) ###--------------------------------------------------------------------------