Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 968451d

Browse files
committed
Trac 15601: get_var() and new_ref() are now functions
1 parent 58a6e8b commit 968451d

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/sage/rings/power_series_pari.pyx

+12-12
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ AUTHORS:
6868
# http://www.gnu.org/licenses/
6969
#*****************************************************************************
7070

71-
from sage.libs.pari.gen cimport gen as pari_gen
72-
from sage.libs.pari.pari_instance cimport pari_instance as pari
71+
from sage.libs.pari.gen cimport gen as pari_gen, new_ref
72+
from sage.libs.pari.pari_instance cimport get_var, pari_instance as pari
7373
from sage.libs.pari.paridecl cimport gel, typ, lg, valp, varn, t_POL, t_SER, t_RFRAC, t_VEC
7474

7575
from sage.misc.superseded import deprecated_function_alias
@@ -92,7 +92,7 @@ cdef PowerSeries_pari construct_from_pari(parent, pari_gen g):
9292
"""
9393
cdef long t = typ(g.g)
9494
v = parent.variable_name()
95-
if t == t_SER and varn(g.g) == pari.get_var(v):
95+
if t == t_SER and varn(g.g) == get_var(v):
9696
prec = lg(g.g) - 2 + valp(g.g)
9797
elif t == t_RFRAC:
9898
prec = parent.default_prec()
@@ -165,7 +165,7 @@ cdef class PowerSeries_pari(PowerSeries):
165165
t = typ(g.g)
166166
if t == t_POL:
167167
g = P(g)._pari_()
168-
elif t == t_SER and varn(g.g) == pari.get_var(v):
168+
elif t == t_SER and varn(g.g) == get_var(v):
169169
if valp(g.g) < 0:
170170
raise ValueError('series has negative valuation')
171171
if prec is infinity:
@@ -661,13 +661,13 @@ cdef class PowerSeries_pari(PowerSeries):
661661
662662
"""
663663
cdef pari_gen g = self.g
664-
cdef long vn = pari.get_var(self._parent.variable_name())
664+
cdef long vn = get_var(self._parent.variable_name())
665665
R = self.base_ring()
666666
if typ(g.g) == t_SER and varn(g.g) == vn:
667667
g = g.truncate()
668668
if typ(g.g) == t_POL and varn(g.g) == vn:
669669
# t_POL has 2 codewords. Use new_ref instead of g[i] for speed.
670-
return [R(pari.new_ref(gel(g.g, i), g)) for i in xrange(2, lg(g.g))]
670+
return [R(new_ref(gel(g.g, i), g)) for i in xrange(2, lg(g.g))]
671671
else:
672672
return [R(g)]
673673

@@ -721,24 +721,24 @@ cdef class PowerSeries_pari(PowerSeries):
721721
cdef long l, m
722722

723723
R = self.base_ring()
724-
if typ(g.g) == t_POL and varn(g.g) == pari.get_var(self._parent.variable_name()):
724+
if typ(g.g) == t_POL and varn(g.g) == get_var(self._parent.variable_name()):
725725
l = lg(g.g) - 2 # t_POL has 2 codewords
726726
if n <= l:
727-
return [R(pari.new_ref(gel(g.g, i + 2), g)) for i in xrange(n)]
727+
return [R(new_ref(gel(g.g, i + 2), g)) for i in xrange(n)]
728728
else:
729-
return ([R(pari.new_ref(gel(g.g, i + 2), g)) for i in xrange(l)]
729+
return ([R(new_ref(gel(g.g, i + 2), g)) for i in xrange(l)]
730730
+ [R.zero()] * (n - l))
731-
elif typ(g.g) == t_SER and varn(g.g) == pari.get_var(self._parent.variable_name()):
731+
elif typ(g.g) == t_SER and varn(g.g) == get_var(self._parent.variable_name()):
732732
l = lg(g.g) - 2 # t_SER has 2 codewords
733733
m = valp(g.g)
734734
if n <= m:
735735
return [R.zero()] * n
736736
elif n <= l + m:
737737
return ([R.zero()] * m
738-
+ [R(pari.new_ref(gel(g.g, i + 2), g)) for i in xrange(n - m)])
738+
+ [R(new_ref(gel(g.g, i + 2), g)) for i in xrange(n - m)])
739739
else:
740740
return ([R.zero()] * m
741-
+ [R(pari.new_ref(gel(g.g, i + 2), g)) for i in xrange(l)]
741+
+ [R(new_ref(gel(g.g, i + 2), g)) for i in xrange(l)]
742742
+ [R.zero()] * (n - l - m))
743743
else:
744744
return [R(g)] + [R.zero()] * (n - 1)

0 commit comments

Comments
 (0)