Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing the issue #6 #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 25 additions & 29 deletions ajpastor/lazy/lazyRing.py
Expand Up @@ -64,17 +64,15 @@ def __init__(self, parent, el):

IntegralDomainElement.__init__(self, parent)

try:
#if(el in parent.poly_ring()):
self.__poly = parent.poly_ring()(str(el))
except:
#elif(el in parent.poly_field()):
try:
self.__poly = parent.poly_field()(str(el))
except:
#else:
self.__raw = parent.base()(el)
self.__poly = self.parent().to_poly(self.__raw)
if(el in parent.poly_ring()):
self.__poly = parent.poly_ring()(el)
elif(el in parent.poly_field()):
self.__poly = parent.poly_field()(el)
elif(el in parent.base()):
self.__raw = parent.base()(el)
self.__poly = self.parent().to_poly(self.__raw)
else:
self.__poly = parent.poly_field()(str(el))

self.simplify()

Expand Down Expand Up @@ -526,26 +524,24 @@ def _element_constructor_(self, *args, **kwds):
i = 1
X = args[i]

try:
if(not isinstance(X, _LazyElement)):
## If the element is not a LazyElement, then we try to create a new element with it
return _LazyElement(self, X)
elif (X.parent() is self):
return X
else:
## Otherwise, X.parent() may have different variables
other = X.parent()
pol = X.poly()

if(not isinstance(X, _LazyElement)):
## If the element is not a LazyElement, then we try to create a new element with it
return _LazyElement(self, X)
elif (X.parent() is self):
return X
else:
## Otherwise, X.parent() may have different variables
other = X.parent()
pol = X.poly()

## For each variable in X.poly(), we get the new polynomial
translate = {}
for var in X.variables():
translate[str(var)] = self.to_poly(other.map_of_vars()[str(var)])
## For each variable in X.poly(), we get the new polynomial
translate = {}
for var in X.variables():
translate[str(var)] = self.to_poly(other.map_of_vars()[str(var)])

## We now plugin the expressions
return _LazyElement(self, pol(**translate))
except TypeError:
raise TypeError("This element can not be casted to %s" %repr(self))
## We now plugin the expressions
return _LazyElement(self, pol(**translate))

def construction(self):
return (LazyRingFunctor(), self.base())
Expand Down