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

Commit

Permalink
update some defunct code
Browse files Browse the repository at this point in the history
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
  • Loading branch information
embray committed Nov 27, 2018
1 parent 3407ae3 commit e2e31f3
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/sage/libs/ntl/ntl_ZZ_pX.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand All @@ -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.")
Expand All @@ -94,16 +101,15 @@ cdef class ntl_ZZ_pX(object):

if isinstance(v, ntl_ZZ_pX) and (<ntl_ZZ_pX>v).c is self.c:
self.x = (<ntl_ZZ_pX>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):
cc = ntl_ZZ_p(x, self.c)
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 ###################
Expand Down

0 comments on commit e2e31f3

Please sign in to comment.