But you can't create a constant Poly without giving the domain. Try 
something like the following (and, again, trace the code to see if there is 
a more direct way of learning the domain):

>>> Poly(1.2+var('x'))
Poly(1.0*x + 1.2, x, domain='RR')
>>> Poly(1+var('x'))
Poly(x + 1, x, domain='ZZ')
>>> Poly(1/S(3)+var('x'))
Poly(x + 1/3, x, domain='QQ')
>>> _.domain
QQ


On Friday, June 27, 2014 10:44:06 AM UTC-5, Aaron Meurer wrote:
>
> If you create a constant Poly, it picks the domain. You should look at 
> the source to see how it picks that. 
>
> Aaron Meurer 
>
> On Sat, Jun 21, 2014 at 10:48 AM, Christophe Bal <proj...@gmail.com 
> <javascript:>> wrote: 
> > Hello. 
> > 
> > I do not know if it is the case but I think that sympy should have a 
> domain 
> > method for expressions. This will avoid error like for example float 
> > calculations raising to 1 for example that wi-ould not be a natural but 
> a 
> > float. 
> > 
> > C. 
> > 
> > 
> > 2014-06-21 17:08 GMT+02:00 Saurabh Jha <saurab...@gmail.com 
> <javascript:>>: 
> > 
> >> I think that makes sense. I think this functionality is already 
> >> implemented in Polys module in some form. I am not able to pin point 
> it. 
> >> 
> >> 
> >>> 
> >>> First, it' unnecessarily slow. 
> >>> Just check whether f == round(f) for floats. 
> >>> 
> >>> Second, the question whether a float is integral or not borders on 
> >>> madness - you never know whether the answer "it's a natural number" 
> >>> comes from the round-off lottery or is genuine. 
> >>> 
> >>> Third, regular expressions aren't going to give any meaningful results 
> >>> for symbolic expressions, and the "Sym" in SymPy defines its mission 
> >>> statement: symbolic math. 
> >>> 
> >>> If you pursue a way to find out whether a *symbolic expression* is in 
> >>> ZZ, QQ, Complex, or whatever, then that would be worth thinking about. 
> >> 
> >> 
> >> 
> >> -- 
> >> You received this message because you are subscribed to the Google 
> Groups 
> >> "sympy" group. 
> >> To unsubscribe from this group and stop receiving emails from it, send 
> an 
> >> email to sympy+un...@googlegroups.com <javascript:>. 
> >> To post to this group, send email to sy...@googlegroups.com 
> <javascript:>. 
> >> Visit this group at http://groups.google.com/group/sympy. 
> >> To view this discussion on the web visit 
> >> 
> https://groups.google.com/d/msgid/sympy/ce634669-04e1-48ab-83b5-7f5c1884b0af%40googlegroups.com.
>  
>
> >> 
> >> For more options, visit https://groups.google.com/d/optout. 
> > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "sympy" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to sympy+un...@googlegroups.com <javascript:>. 
> > To post to this group, send email to sy...@googlegroups.com 
> <javascript:>. 
> > Visit this group at http://groups.google.com/group/sympy. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/sympy/CAAb4jGmQzk3FqVpMCUDUhr8w%2ByiibM3fSz_eMJ0S1O_6_wqveQ%40mail.gmail.com.
>  
>
> > 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/d5c5d2f1-e19c-4010-9fd7-1008929c268a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to