On Dec 13, 4:46 pm, John H Palmieri <jhpalmier...@gmail.com> wrote:
> I was thinking of adding some doctests, so I was looking at
> algebra_ideal.py. Now I'm confused.
>
> The file has lines (plus some documentation, which I'm omitting):
>
> class AlgebraIdeal(object):
> def __init__(self, A, gens = []):
> if not isinstance(A, Algebra): raise TypeError, "Argument A
> must be an algebra."
> self.__algebra = A
> self.__gens = gens
>
> Now from within sage:
>
> sage: from sage.algebras.algebra_ideal import *
> sage: R.<y,z> = FreeAlgebra(QQ, 2)
> sage: J = AlgebraIdeal(R, [y^2])
>
> Then J.__gens is not defined, and neither is J.__algebra. Instead,
> J._AlgebraIdeal__gens and J._AlgebraIdeal__algebra are defined, with
> the appropriate values.
>
> Questions:
>
> 1. is this something built into the object class, from which
> AlgebraIdeal inherits, or is this happening for some other reason? If
> the latter, what's going on?
> 2. is the object class the right class to use here? (I would point
> that in sage.rings.ideal, Ideal_generic inherits from MonoidElement,
> which strikes me as a little odd. I'm not going to worry about
> ideal.py right now, but for AlgebraIdeal, perhaps Parent would be the
> right class?)
>
> John
Also it's very bad to have an initialiser like gens = [], because e.g.
>>> class A:
... def __init__(self, x=[]):
... self.y = x
...
>>> a = A()
>>> a.y
[]
>>> a.y.append(3)
>>> b = A()
>>> b.y
[3]
david
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---