Skip to content

Commit f0fecef

Browse files
committed
Deprecate get_var(-1)
1 parent 860c9b6 commit f0fecef

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

cypari2/gen.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2374,7 +2374,7 @@ cdef class Gen(Gen_auto):
23742374
R -= 1
23752375
return new_gen(v)
23762376

2377-
def Ser(f, v=-1, long precision=-1):
2377+
def Ser(f, v=None, long precision=-1):
23782378
"""
23792379
Return a power series or Laurent series in the variable `v`
23802380
constructed from the object `f`.
@@ -3755,7 +3755,7 @@ cdef class Gen(Gen_auto):
37553755
sig_on()
37563756
return new_gen(eltreltoabs(self.g, t0.g))
37573757

3758-
def galoissubfields(self, long flag=0, v=-1):
3758+
def galoissubfields(self, long flag=0, v=None):
37593759
"""
37603760
List all subfields of the Galois group ``self``.
37613761
@@ -4298,7 +4298,7 @@ cdef class Gen(Gen_auto):
42984298
sig_on()
42994299
return new_gen(factorpadic(self.g, t0.g, r))
43004300

4301-
def poldegree(self, var=-1):
4301+
def poldegree(self, var=None):
43024302
"""
43034303
Return the degree of this polynomial.
43044304
"""

cypari2/pari_instance.pyx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ cdef long get_var(v) except -2:
13281328
Convert ``v`` into a PARI variable number.
13291329
13301330
If ``v`` is a PARI object, return the variable number of
1331-
``variable(v)``. If ``v`` is ``None`` or ``-1``, return -1.
1331+
``variable(v)``. If ``v`` is ``None``, return -1.
13321332
Otherwise, treat ``v`` as a string and return the number of
13331333
the variable named ``v``.
13341334
@@ -1354,6 +1354,8 @@ cdef long get_var(v) except -2:
13541354
2*x
13551355
>>> pari("[Pi,0]").Pol('!@#$%^&')
13561356
3.14159265358979*!@#$%^&
1357+
>>> pari("[1,0]").Pol(-1) # Deprecated
1358+
x
13571359
13581360
We can use ``varhigher()`` and ``varlower()`` to create
13591361
temporary variables without a name. The ``"xx"`` below is just a
@@ -1383,6 +1385,8 @@ cdef long get_var(v) except -2:
13831385
else:
13841386
return varno
13851387
if v == -1:
1388+
from warnings import warn
1389+
warn("using '-1' as variable name is deprecated, use 'None' to mean 'no variable'", DeprecationWarning)
13861390
return -1
13871391
cdef bytes s = to_bytes(v)
13881392
sig_on()

0 commit comments

Comments
 (0)