Hi, Agreed that Magma
> I'll just come out and say it -- It's a _terrible_ design in Magma. +1. > Yet another example of the Magma semantics being a pain. > They don't even use a notion of None. Argh. +1 ; Although there is a syntax to denote no argument (return x, _;) The problem is that in Magma x, y := SomeFunction(a,b,c,...) just ignores the existence of y (if _ is the return value) rather than assigning a None (which doesn't exist as a Magma object) to it. > E1.is_isomorphic(E2) > > always returns one boolean. +1 > 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. This is my question: do we have functions which can return different types depending on the arguments passed in? Whatever its design flaws, it has been the philosophy that this should not be the case in Magma. The alternative is to have a different function: E1.is_isomorphic_with_isomorphism(E2) # or is_isomorphic_with_map I would like to hear from someone on the "correct" Python style. Note that this syntax should be followed throughout the SAGE language, in groups, rings, etc., so we should have a convention. I would also propose the syntax: E1.isomorphism(E2) rather than E1.isomorphism_to(E2) as the direction should be clear. The latter implies E1.isomorphism_from(E2) should also exist, but I don't see an argument or context in which E1.isomorphism(E2) and E2.isomorphism(E1) would not suffice. Thus we could have: E1.is_isomorphic(E2) E1.is_isomorphic_with_isomorphism(E2) # or E1.is_isomorphic_with_map(E2) E1.isomorphism(E2) The middle one could be replaced with E1.is_isomorphism(E2,with_isomorphism=True) (of with_map) if this is judged acceptable SAGE/Python syntax. I would propose we endeavor to have the same return type (or None) independent of the arguments given. John mentioned calculation of all isomorphisms. I propose that the set of all isomorphisms be a SAGE object. Thus X = Iso(E1,E2) # does nothing X.cardinality() # tests is_isomorphic and j-invariant = 0 or 12^3 X.representative() # computes an isomorphism X.list() # computes all isomorphisms The advantage of creating X is that it can cache the above data for efficiency. Moreover is E1 = E2, we could do G = Aut(E1) # or Iso(E1,E1) G.group() G.group_with_isomorphism() A = AbelianGroup(2) A.is_isomorphic(G) A.is_isomorphic_with_isomorphism(G) A.isomorphism(G) Again, this should be a common syntax throughout SAGE. --David 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/ -~----------~----~----~----~------~----~------~--~---