Skip to content

Commit 31bd9cc

Browse files
author
Release Manager
committed
sagemathgh-41189: Accept both 'implementation' and 'impl' parameters for GF() <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> 1.Changed primary parameter from impl to implementation in docstrings 2.Marked impl as deprecated (backwards compatibility) 3.Updated examples to use implementation instead of impl 4.Added examples showing both parameters work 5. clean commit history @nbruin review this ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> related to sagemath#41123 URL: sagemath#41189 Reported by: Adnan Nazir Reviewer(s): Chenxin Zhong, Vincent Macri
2 parents fda4ce3 + e98ec9c commit 31bd9cc

13 files changed

+213
-195
lines changed

src/sage/categories/pushout.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3294,7 +3294,12 @@ def __init__(self, polys, names, embeddings=None, structures=None,
32943294
if latex_names[i] == latex_variable_name(name):
32953295
latex_names[i] = None
32963296
self.latex_names = latex_names
3297-
self.kwds = kwds
3297+
kwds_self = dict(kwds.items())
3298+
if 'implementation' in kwds_self:
3299+
assert len(self.polys) == 1
3300+
self.implementations = [kwds_self['implementation']]
3301+
del kwds_self['implementation']
3302+
self.kwds = kwds_self
32983303

32993304
def _apply_functor(self, R):
33003305
"""
@@ -3529,11 +3534,7 @@ def merge(self, other):
35293534
# integers to encode degrees of extensions.
35303535
from sage.rings.integer import Integer
35313536
kwds_self = dict(self.kwds.items())
3532-
if 'impl' in kwds_self:
3533-
del kwds_self['impl']
35343537
kwds_other = dict(other.kwds.items())
3535-
if 'impl' in kwds_other:
3536-
del kwds_other['impl']
35373538
if (isinstance(self.polys[0], Integer)
35383539
and isinstance(other.polys[0], Integer)
35393540
and self.embeddings == other.embeddings == [None]

src/sage/homology/homology_vector_space_with_basis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1444,7 +1444,7 @@ def is_GF2(R):
14441444
sage: from sage.homology.homology_vector_space_with_basis import is_GF2
14451445
sage: is_GF2(GF(2))
14461446
True
1447-
sage: is_GF2(GF(2, impl='ntl'))
1447+
sage: is_GF2(GF(2, implementation='ntl'))
14481448
True
14491449
sage: is_GF2(GF(3))
14501450
False

src/sage/modules/free_module_element.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ cdef class FreeModuleElement(Vector): # abstract base class
10851085
Create the multiplication table of `GF(4)` using GP::
10861086
10871087
sage: # needs sage.libs.pari
1088-
sage: k.<a> = GF(4, impl='pari_ffelt')
1088+
sage: k.<a> = GF(4, implementation="pari_ffelt")
10891089
sage: v = gp(vector(list(k)))
10901090
sage: v
10911091
[0, 1, a, a + 1]

src/sage/rings/finite_rings/element_base.pyx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -738,16 +738,16 @@ cdef class FinitePolyExtElement(FiniteRingElement):
738738
739739
EXAMPLES::
740740
741-
sage: k.<a> = FiniteField(9, impl='givaro', modulus='primitive') # needs sage.libs.linbox
741+
sage: k.<a> = FiniteField(9, implementation='givaro', modulus='primitive') # needs sage.libs.linbox
742742
sage: a.is_square() # needs sage.libs.linbox
743743
False
744744
sage: (a**2).is_square() # needs sage.libs.linbox
745745
True
746-
sage: k.<a> = FiniteField(4, impl='ntl', modulus='primitive') # needs sage.libs.ntl
746+
sage: k.<a> = FiniteField(4, implementation='ntl', modulus='primitive') # needs sage.libs.ntl
747747
sage: (a**2).is_square() # needs sage.libs.ntl
748748
True
749-
sage: k.<a> = FiniteField(17^5, impl='pari_ffelt', modulus='primitive') # needs sage.libs.pari
750-
sage: a.is_square() # needs sage.libs.pari
749+
sage: k.<a> = FiniteField(17^5, implementation='pari_ffelt', modulus='primitive') # needs sage.libs.pari
750+
sage: a.is_square()
751751
False
752752
sage: (a**2).is_square() # needs sage.libs.pari
753753
True
@@ -796,7 +796,7 @@ cdef class FinitePolyExtElement(FiniteRingElement):
796796
3
797797
sage: F(4).square_root()
798798
2
799-
sage: K = FiniteField(7^3, 'alpha', impl='pari_ffelt')
799+
sage: K = FiniteField(7^3, 'alpha', implementation='pari_ffelt')
800800
sage: K(3).square_root()
801801
Traceback (most recent call last):
802802
...

src/sage/rings/finite_rings/element_givaro.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,12 +580,12 @@ cdef class Cache_givaro(Cache_base):
580580
sage: k._cache._element_repr(a^20)
581581
'2*a^3 + 2*a^2 + 2'
582582
583-
sage: k = FiniteField(3^4,'a', impl='givaro', repr='int')
583+
sage: k = FiniteField(3^4,'a', implementation='givaro', repr='int')
584584
sage: a = k.gen()
585585
sage: k._cache._element_repr(a^20)
586586
'74'
587587
588-
sage: k = FiniteField(3^4,'a', impl='givaro', repr='log')
588+
sage: k = FiniteField(3^4,'a', implementation='givaro', repr='log')
589589
sage: a = k.gen()
590590
sage: k._cache._element_repr(a^20)
591591
'20'

src/sage/rings/finite_rings/element_ntl_gf2e.pyx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ cdef class Cache_ntl_gf2e(Cache_base):
144144
145145
TESTS::
146146
147-
sage: k.<a> = GF(2^8, impl='ntl')
147+
sage: k.<a> = GF(2^8, implementation="ntl")
148148
"""
149149
self._parent = <FiniteField?>parent
150150
self._zero_element = self._new()
@@ -262,10 +262,10 @@ cdef class Cache_ntl_gf2e(Cache_base):
262262
263263
We can coerce from PARI finite field implementations::
264264
265-
sage: K.<a> = GF(2^19, impl='ntl')
265+
sage: K.<a> = GF(2^19, implementation="ntl")
266266
sage: a^20
267267
a^6 + a^3 + a^2 + a
268-
sage: M.<c> = GF(2^19, impl='pari_ffelt')
268+
sage: M.<c> = GF(2^19, implementation="pari_ffelt")
269269
sage: K(c^20)
270270
a^6 + a^3 + a^2 + a
271271
"""
@@ -501,7 +501,7 @@ cdef class FiniteField_ntl_gf2eElement(FinitePolyExtElement):
501501
502502
EXAMPLES::
503503
504-
sage: k.<a> = GF(2^8, impl='ntl') # indirect doctest
504+
sage: k.<a> = GF(2^8, implementation="ntl") # indirect doctest
505505
"""
506506
if parent is None:
507507
return
@@ -998,7 +998,7 @@ cdef class FiniteField_ntl_gf2eElement(FinitePolyExtElement):
998998
999999
EXAMPLES::
10001000
1001-
sage: k.<a> = GF(2^8, impl='ntl')
1001+
sage: k.<a> = GF(2^8, implementation="ntl")
10021002
sage: b = a^3 + a
10031003
sage: b.minpoly()
10041004
x^4 + x^3 + x^2 + x + 1

0 commit comments

Comments
 (0)