global namespace

16 views
Skip to first unread message

Martin Albrecht

unread,
Aug 31, 2011, 12:43:56 PM8/31/11
to Sage Development
Hi,

at

http://trac.sagemath.org/sage_trac/ticket/11764

Paul Zimmermann writes:

"""
for univariate polynomials we have the class Polynomial:

sage: R.<x> = QQ[]
sage: isinstance(x+1, Polynomial)
True
However for multivariate polynomials we have to write:

sage: R.<x,y> = QQ[]
sage: isinstance(x+y, sage.rings.polynomial.multi_polynomial.MPolynomial)
True
I suggest MPolynomial is defined as an alias for
sage.rings.polynomial.multi_polynomial.MPolynomial so that we can
simply write:

sage: R.<x,y> = QQ[]
sage: isinstance(x+y, MPolynomial)
True
"""

I suggested this needs a discussion on [sage-devel] because it's about
adding *more* stuff to the global namespace, while we try to keep that
to a minimum.

Thoughts?
Martin

--
name: Martin Albrecht
_pgp: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99
_otr: 47F43D1A 5D68C36F 468BAEBA 640E8856 D7951CCF
_www: http://www.informatik.uni-bremen.de/~malb
_jab: martinr...@jabber.ccc.de

William Stein

unread,
Aug 31, 2011, 1:46:20 PM8/31/11
to sage-...@googlegroups.com
On Wed, Aug 31, 2011 at 9:43 AM, Martin Albrecht
<martinr...@googlemail.com> wrote:
> Hi,
>
> at
>
>    http://trac.sagemath.org/sage_trac/ticket/11764
>
> Paul Zimmermann writes:
>
> """
> for univariate polynomials we have the class Polynomial:
>
> sage: R.<x> = QQ[]
> sage: isinstance(x+1, Polynomial)
> True
> However for multivariate polynomials we have to write:
>
> sage: R.<x,y> = QQ[]
> sage: isinstance(x+y, sage.rings.polynomial.multi_polynomial.MPolynomial)
> True
> I suggest MPolynomial is defined as an alias for
> sage.rings.polynomial.multi_polynomial.MPolynomial so that we can
> simply write:
>
> sage: R.<x,y> = QQ[]
> sage: isinstance(x+y, MPolynomial)
> True
> """
>
> I suggested this needs a discussion on [sage-devel] because it's about
> adding *more* stuff to the global namespace, while we try to keep that
> to a minimum.

Random Thoughts: Since we banned using "is_MPolynomial", and we do
have Polynomial in the global namespace, I can't see an alternative to
having MPolynomial. That said, it's perhaps bad that we have
Polynomial in the global namespace. I wonder how many people have
done:

sage: Polynomial(2)
boom!
sage: Polynomial([1,2,3])
boom!
sage: Polynomial(QQ,[1,2,3])
boom!
sage: Polynomial?
pages, with nothing about how to make a polynomial using "the
Polynomial command"...

-- William

Simon King

unread,
Aug 31, 2011, 4:12:56 PM8/31/11
to sage-devel
Hi Martin, Paul and William,

On 31 Aug., 19:46, William Stein <wst...@gmail.com> wrote:
> Random Thoughts:  Since we banned using "is_MPolynomial", and we do
> have Polynomial in the global namespace, I can't see an alternative to
> having MPolynomial.  That said, it's perhaps bad that we have
> Polynomial in the global namespace.

I wouldn't mind to remove Polynomial from the global name space, since
it is hardly useful and may actually be confusing (polynomials ought
to be created differently), as William has pointed out.

Cheers,
Simon
Reply all
Reply to author
Forward
0 new messages