On 2018-03-28, saad khalid <saad1...@gmail.com> wrote: > So, in this case, > it Should assume that 3/1 is referring to the integer 3, use is_prime on > the integer, and then also give a warning stating that 3/1 was interpreted > as the integer 3. Then, we should have a function like is_prime_in_ring, > which functions the way is_prime functions right now, ie it takes into > account what the parent was instead of making the common simplification. > The warning I mentioned earlier could even tell the use that if they want a > ring dependent result, then they should use is_prime_in_ring. Again, the > vast majority of users are assuming 3/1 = 3, and paying attention to the > parent is a case of special usage.
That makes sense to me. Thus I now think, z.is_prime() should roughly work like this: def is_prime(self): P = self.parent() if P in Fields(): try: R = P.ring_of_integers() except AttributeError: R = P if self not in R: return False if P is not R: deprecation(<relevant ticket>, """ You are testing primality of {}, which was constructed as an element of {}. We assume that you want a primality test in {}. If this was not your intention, use .is_prime_in_ring(<ring>)""".format(self,P,R)) P = R return self.is_prime_in_ring(P) and def is_prime_in_ring(self,R=None): if R is None: R = self.parent() return <whether self is a prime in R> Not so sure if "deprecation" is the right thing, as the plan is not to eventually remove a functionality. But at least in that way the warning would be printed only once, and after all it *is* deprecated to use is_prime for primality test in a field (use is_prime_in_ring instead). Best regards, Simon -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.