Re: [sage-devel] is_prime failing silently

2016-02-07 Thread David Roe
On Sun, Feb 7, 2016 at 9:16 AM, Travis Scrimshaw wrote: > > > On Sunday, February 7, 2016 at 7:54:03 AM UTC-6, Jeroen Demeyer wrote: >> >> On 2016-02-07 14:50, Travis Scrimshaw wrote: >> > So then what do you think about the current behavior, where if there >> > is no (implemented) is_prime(), we

Re: [sage-devel] is_prime failing silently

2016-02-07 Thread Travis Scrimshaw
On Sunday, February 7, 2016 at 7:54:03 AM UTC-6, Jeroen Demeyer wrote: > > On 2016-02-07 14:50, Travis Scrimshaw wrote: > > So then what do you think about the current behavior, where if there > > is no (implemented) is_prime(), we then try to convert to ZZ? > > We don't *try* to convert, we j

Re: [sage-devel] is_prime failing silently

2016-02-07 Thread Jeroen Demeyer
On 2016-02-07 14:50, Travis Scrimshaw wrote: So then what do you think about the current behavior, where if there is no (implemented) is_prime(), we then try to convert to ZZ? We don't *try* to convert, we just convert. No problem with that. -- You received this message because you are subscri

Re: [sage-devel] is_prime failing silently

2016-02-07 Thread Travis Scrimshaw
On Saturday, February 6, 2016 at 3:29:49 AM UTC-6, Jeroen Demeyer wrote: > > On 2016-02-06 00:07, Travis Scrimshaw wrote: > > try to coerce it to the base ring > -1 > > These kind of conditionals only make things worse. Either you convert to > the base ring or you don't convert to the base ri

Re: [sage-devel] is_prime failing silently

2016-02-06 Thread Jeroen Demeyer
On 2016-02-06 00:07, Travis Scrimshaw wrote: try to coerce it to the base ring -1 These kind of conditionals only make things worse. Either you convert to the base ring or you don't convert to the base ring. But *trying* to convert is the most confusing thing you can do. Jeroen. -- You rec

Re: [sage-devel] is_prime failing silently

2016-02-05 Thread Travis Scrimshaw
On Friday, February 5, 2016 at 3:29:29 PM UTC-6, Jeroen Demeyer wrote: > > On 2016-02-05 19:59, William Stein wrote: > > Maybe is_prime for field elements should just raise an exception? > > This reminds me very much about the recent discussion we had about floor > division... and which didn't

Re: [sage-devel] is_prime failing silently

2016-02-05 Thread Jeroen Demeyer
On 2016-02-05 19:59, William Stein wrote: Maybe is_prime for field elements should just raise an exception? This reminds me very much about the recent discussion we had about floor division... and which didn't really come to a conclusion. It's really the same problem: you have something whic

Re: [sage-devel] is_prime failing silently

2016-02-05 Thread Jeroen Demeyer
On 2016-02-05 20:45, Vincent Delecroix wrote: About the code, the current version is {{{ def is_prime(n): try: return n.is_prime() except (AttributeError, NotImplementedError): return ZZ(n).is_prime() }}} I think that we should change it to {{{ from sage.structure.c

Re: [sage-devel] is_prime failing silently

2016-02-05 Thread William Stein
On Fri, Feb 5, 2016 at 9:50 AM, David Wong wrote: > prime_number = bignumber / 2 > is_prime(prime_number) # -> False > > prime_number = bignumber // 2 > is_prime(prime_number) # -> True > > prime_number = ZZ(bignumber / 2) > is_prime(prime_number) # -> True > > > I've spent a couple of days arguin

Re: [sage-devel] is_prime failing silently

2016-02-05 Thread Vincent Delecroix
About the code, the current version is {{{ def is_prime(n): try: return n.is_prime() except (AttributeError, NotImplementedError): return ZZ(n).is_prime() }}} I think that we should change it to {{{ from sage.structure.coerce import py_scalar_to_element def is_prime(n):

Re: [sage-devel] is_prime failing silently

2016-02-05 Thread William Stein
On Fri, Feb 5, 2016 at 11:24 AM, Bruno Grenet wrote: > Note that there is a difference between the example in the original email > and the answers: The original email was about is_prime(something) not > something.is_prime(). I do not know the mechanisms behind > is_prime(something) but would it be

Re: [sage-devel] is_prime failing silently

2016-02-05 Thread Bruno Grenet
Note that there is a difference between the example in the original email and the answers: The original email was about is_prime(something) not something.is_prime(). I do not know the mechanisms behind is_prime(something) but would it be possible that in this case the behavior is slightly differ

Re: [sage-devel] is_prime failing silently

2016-02-05 Thread William Stein
On Friday, February 5, 2016, David Roe wrote: > > > On Fri, Feb 5, 2016 at 1:20 PM, Vincent Delecroix < > 20100.delecr...@gmail.com > > wrote: > >> Hello, >> >> Indeed, the definition given in the documentation of "is_prime" does not >> coincide with what the method is doing. >> >> The mathematic

Re: [sage-devel] is_prime failing silently

2016-02-05 Thread David Roe
On Fri, Feb 5, 2016 at 1:20 PM, Vincent Delecroix <20100.delecr...@gmail.com > wrote: > Hello, > > Indeed, the definition given in the documentation of "is_prime" does not > coincide with what the method is doing. > > The mathematical definition of prime *depends* on the ring. An element of > a ri

Re: [sage-devel] is_prime failing silently

2016-02-05 Thread Vincent Delecroix
Hello, Indeed, the definition given in the documentation of "is_prime" does not coincide with what the method is doing. The mathematical definition of prime *depends* on the ring. An element of a ring is prime if the ideal it generates is prime. And the ideal (3) is prime in ZZ but not in QQ

[sage-devel] is_prime failing silently

2016-02-05 Thread David Wong
prime_number = bignumber / 2 is_prime(prime_number) # -> False prime_number = bignumber // 2 is_prime(prime_number) # -> True prime_number = ZZ(bignumber / 2) is_prime(prime_number) # -> True I've spent a couple of days arguing with people about a number (not) being a prime. Turns out it fails