From e2e31f35b62a7c8da831205567c8e1cdb43179bd Mon Sep 17 00:00:00 2001 From: "Erik M. Bray" Date: Mon, 26 Nov 2018 15:22:50 +0000 Subject: [PATCH] update some defunct code this appears to support a flimsy hack for other types that might look like a list of integers (hence the .replace(',', '').replace('L', '')) but this is bad I can't find any examples either in the EXAMPLE or TEST blocks that test this case explicitly or implicitly, so I'm just going to claim it's unsupported. However, what *should* be supported is accpting str or bytes explicitly in the NTL format for polynomials --- src/sage/libs/ntl/ntl_ZZ_pX.pyx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/sage/libs/ntl/ntl_ZZ_pX.pyx b/src/sage/libs/ntl/ntl_ZZ_pX.pyx index cedfd172f7b..6be0b73035c 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pX.pyx +++ b/src/sage/libs/ntl/ntl_ZZ_pX.pyx @@ -68,7 +68,7 @@ cdef class ntl_ZZ_pX(object): or Karatsuba algorithms. """ # See ntl_ZZ_pX.pxd for definition of data members - def __init__(self, v = None, modulus = None): + def __init__(self, v=None, modulus=None): """ EXAMPLES:: @@ -83,6 +83,13 @@ cdef class ntl_ZZ_pX(object): [0 0 0 0 0 0 0 0 0 0 5] sage: g[10] 5 + + NTL polynomial string inputs are also accepted:: + + sage: ntl.ZZ_pX('[1 2 5 11]', c) + [1 2 5 11] + sage: ntl.ZZ_pX(b'[1 2 5 11]', c) + [1 2 5 11] """ if modulus is None: raise ValueError("You must specify a modulus when creating a ZZ_pX.") @@ -94,6 +101,8 @@ cdef class ntl_ZZ_pX(object): if isinstance(v, ntl_ZZ_pX) and (v).c is self.c: self.x = (v).x + elif isinstance(v, (bytes, str)): + ccreadstr(self.x, v) elif issequence(v): for i, x in enumerate(v): if not isinstance(x, ntl_ZZ_p): @@ -101,9 +110,6 @@ cdef class ntl_ZZ_pX(object): else: cc = x ZZ_pX_SetCoeff(self.x, i, cc.x) - elif v is not None: - s = str(v).replace(',',' ').replace('L','') - ccreadstr(self.x, s) def __cinit__(self, v=None, modulus=None): #################### WARNING ###################