[sage-support] Re: How to do: is_Integer(sqrt(a^2+b^2))

2008-09-26 Thread mabshoff



On Sep 26, 12:06 am, Robert Bradshaw [EMAIL PROTECTED]
wrote:

SNIP

  Indeed!  I like Mike Hansen's (or your) proposal to get
  rid of them all from the global namespace, and replace
  them only by is_lowercase_method_name functions
  that are all conceptually meaningful.   Of course leave
  the type-checking is_Uppercase's around, but don't
  put them in all.py's.

  What do you guys think?

 +1 for sure.

The patch is up at #4192 and will be merge shortly unless there is
some last minute breakage.

SNIP

 - Robert

Cheers,

Michael
--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: How to do: is_Integer(sqrt(a^2+b^2))

2008-09-25 Thread William Stein

On Thu, Sep 25, 2008 at 5:33 PM, Quicksilver_Johny
[EMAIL PROTECTED] wrote:

 If c=sqrt(a^2+b^2)
 How would I check if c is an integer in order to get a true/false
 value.
 I tried is_Integer(ZZ(c)), this returns true when c is an integer, but
 ZZ(c) returns an error when c is not an integer.

Try using Python's try/except:

try:
ZZ(c)
# c is an integer
except TypeError:
# c isn't an integer

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---



[sage-support] Re: How to do: is_Integer(sqrt(a^2+b^2))

2008-09-25 Thread Robert Bradshaw


On Sep 25, 2008, at 5:43 PM, William Stein wrote:


 On Thu, Sep 25, 2008 at 5:33 PM, Quicksilver_Johny
 [EMAIL PROTECTED] wrote:

 If c=sqrt(a^2+b^2)
 How would I check if c is an integer in order to get a true/false
 value.
 I tried is_Integer(ZZ(c)), this returns true when c is an integer,  
 but
 ZZ(c) returns an error when c is not an integer.

 Try using Python's try/except:

 try:
 ZZ(c)
 # c is an integer
 except TypeError:
 # c isn't an integer

These is_* sure are causing a lot of confusion lately...

Rational numbers also have an is_integral method, so you could also do

c=sqrt(a^2+b^2)
if c.is_integral():
# c is an integer

- Robert

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~--~~~~--~~--~--~---