forked from sagemath/sage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sagemathgh-37613: Fix hyperelliptic curve dynamic class construction …
…to allow proper method inheritance While working on some hyperelliptic code, I realised the dynamic class construction had an issue with inheritance for the genus two classes and certain methods which should have been available were not. This is discussed in more detail in the issue sagemath#37612 I do not know a *good* fix for this, but I have found a fix which at least allows the functions supposed to be accessed to be accessed. I have added a small doctest to ensure that the method called for genus two curves is bound to the correct class. ## Overview of the fix The original class was constructed as: ```py cls = dynamic_class(class_name, tuple(superclass), cls=HyperellipticCurve_generic, doccls=HyperellipticCurve) ``` Where `superclass` is either an empty list, a list with a single child from: - `HyperellipticCurve_finite_field` - `HyperellipticCurve_rational_field` - `HyperellipticCurve_padic_field` - `HyperellipticCurve_g2` Notice that all four of these classes are children of `HyperellipticCurve_generic`. Or, in the case of the base field being one of the above AND the curve being genus two this list is of the form: ``` [HyperellipticCurve_XXX_field, HyperellipticCurve_g2] ``` In this case, I found that the dynamic class insertion into `cls` meant that the methods shared by one of the "`superclass`" (probably should be called base classes?) and `cls` itself would call the method from `cls` rather than the superclass and so all specialised functions were unavailable, making the genus two optimisations redundant. In my new fix, if `superclass` has a length of zero, I set `cls` to be `HyperellipticCurve_generic`, otherwise `cls` is `None`. This seems to work, but I don't know if this is good practice. Fixes sagemath#37612 URL: sagemath#37613 Reported by: Giacomo Pope Reviewer(s): Giacomo Pope, Kwankyu Lee
- Loading branch information
Showing
2 changed files
with
58 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters