On Jan 16, 2008 12:34 PM, John Cremona <[EMAIL PROTECTED]> wrote:
> William is right that with Python there is no need to have variable
> numbers of return variables (for Python functions, I don't mean
> Magma).  In situations like is_isomorphic() we can always return a
> tuple of 2 values, either (true, i) with i an isomorphism or (false,
> None).  So the calling program can unpack the tuple into 2 values and
> only look at the second if the first is true.  However that breaks
> code which looks correct if written simply as
> if E2.is_isomorphic(E2):
>   do something

Hmm.  I think it should be that

    E1.is_isomorphic(E2)

always returns one boolean.   If you want the map too, you have write
something explicit, e.g.,

   t, phi = E1.is_isomorphic(E2, with_map=True)

where phi will be None they aren't isomorphic.   As long as there are examples
and documentation this is easy to use and very easy to read.

Justin says:
> Trying to unwind code that relies
> on this will be a headache, and we should be considering
> maintainability as we go.  It's always tough to start tackling a
> large code base long after the original developers have moved on, and
> this kind of trickery won't help a bit.

In any case, we have to make it possible to use things in Magma from
Sage that people want to use.  Just not doing so isn't an option.

> Still on this specific subthread, I think there must be many
> situations where as well as David's comment that computing one iso is
> not much more work than checking if one exists, one can compute *all*
> isos in not much more time than computing one.  In that case I would
> want to implement E1.isomorphisms_to(E2) [note the "s"!]  which
> returns a possibly empty list of all iso's from E1 to E2.  Then
> E1.is_isomorphic_to(E2) can be *literally* synonymous with
> E1.isomorphisms_to(E2) thanks to Pythons convention that a list is
> "true" if and only if not empty (you can see that I have been reading
> up on Python!).  And then E1.isomorphism_to(E2) can return
> E1.isomorphisms_to(E2)[0] with suitable error-catching if the list was
> empty.  And finally, E1.isomorphisms_to(E1) would return the set of
> automorphisms of E1.

I don't think I like that.  Shouldn't a function named
is_something(...) return True
or False by default?   Taking this further, what would you do with n.is_prime()
for n an integer?   Or with something like x.is_zero_divisor()?

> All the above is certainly good for the case of ellitpic curves which
> have finite automorphsm groups (and almost always of size 2) so the
> above lists are mainly of length 0 or 2.  But maybe elsewhere too?
>
> John
>

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@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-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to