def__contains__(self,other):result=self.contains(other)ifresultisNone:raiseTypeError('contains did not evaluate to a bool')returnresultdef_eval_subs(self,old,new):ifold.is_Symbolandoldinself.variables:i=self.variables.index(old)newexpr=self.expr._subs(old,new)ifisinstance(new,Symbol):newvars=list(self.variables)newvars[i]=newnewpt=self.pointelse:newvars=tuple(newexpr.free_symbols)+ \
self.variables[:i]+self.variables[i+1:]newpt=self.point[0]**(new.as_numer_denom()[1].is_number*2-1)newpt=[newpt]*len(newvars)returnOrder(newexpr,*zip(newvars,newpt))returnOrder(self.expr._subs(old,new),*self.args[1:])def_eval_conjugate(self):expr=self.expr._eval_conjugate()ifexprisnotNone:returnself.func(expr,*self.args[1:])def_eval_derivative(self,x):returnself.func(self.expr.diff(x),*self.args[1:])orselfdef_eval_transpose(self):expr=self.expr._eval_transpose()ifexprisnotNone:returnself.func(expr,*self.args[1:])def_sage_(self):#XXX: SAGE doesn't have Order yet. Let's return 0 instead.returnRational(0)._sage_()