Tab completion finds methods that don't seem to exist

2 views
Skip to first unread message

Jason Bandlow

unread,
Jun 3, 2010, 3:40:54 PM6/3/10
to sage-...@googlegroups.com
Hi all,

I'm getting the following behavior on my local sage-4.4.2 and on sagenb.org:

sage: R.<x> = QQ[]
sage: R.su<tab>
R.sum R.summation
R.summation_from_element_class_add
sage: R.sum?
Object `R.sum` not found.
sage: R.sum()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)

/usr/local/src/sage/sage-4.4.2/devel/sage-trac/sage/rings/polynomial/<ipython
console> in <module>()

/usr/local/src/sage/sage-4.4.2/local/lib/python2.6/site-packages/sage/structure/parent.so
in sage.structure.parent.Parent.__getattr__ (sage/structure/parent.c:5264)()

/usr/local/src/sage/sage-4.4.2/local/lib/python2.6/site-packages/sage/structure/parent.so
in sage.structure.parent.raise_attribute_error
(sage/structure/parent.c:2622)()

AttributeError: 'PolynomialRing_field' object has no attribute 'sum'


The same thing happens with `summation` and
`summation_from_element_class_add`, and various other methods (for
instance `R.addition_table`). It also happens for both single variable
and multi-variable polynomial rings. Is this behavior known, or should
I open a ticket?

Thanks,
Jason Bandlow

Simon King

unread,
Jun 4, 2010, 4:13:35 AM6/4/10
to sage-devel
Hi!

Another data point: In your example above, one has
sage: 'sum' in dir(R)
True
sage: R.__dict__['sum']

---------------------------------------------------------------------------
KeyError Traceback (most recent call
last)

/home/king/<ipython console> in <module>()

KeyError: 'sum'

So, introspection seems to be seriously screwed up.

R has both a __getattr__ and a __dir__ method that seem to be rather
generic. Is this part of the combinat/category framework? So, my
uneducated guess is that R belongs to a category whose objects
*should* provide a sum method, but nobody has implemented it (though
"sum" sounds like there could be generic code for it as well).

Cheers,
Simon

Florent Hivert

unread,
Jun 4, 2010, 4:27:08 AM6/4/10
to sage-...@googlegroups.com
Hi Simon,

One remark to support your guess:

sage: R._test_category()
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)

/usr/local/sage/sage-4.4.2/local/lib/python2.6/site-packages/Sphinx-0.6.3-py2.6.egg/sphinx/<ipython console> in <module>()

/usr/local/sage/sage/local/lib/python2.6/site-packages/sage/structure/parent.so in sage.structure.parent.Parent._test_category (sage/structure/parent.c:4730)()

/usr/local/sage/sage/local/lib/python/unittest.pyc in failUnless(self, expr, msg)
323 def failUnless(self, expr, msg=None):
324 """Fail the test unless the expression is true."""
--> 325 if not expr: raise self.failureException, msg
326
327 def failUnlessRaises(self, excClass, callableObj, *args, **kwargs):

AssertionError: category of self improperly initialized

Cheers,

Florent

Jason Bandlow

unread,
Jun 4, 2010, 9:44:11 AM6/4/10
to sage-...@googlegroups.com
Thanks Simon and Florent,

This is now http://trac.sagemath.org/sage_trac/ticket/9138 .


Nicolas M. Thiery

unread,
Jun 5, 2010, 11:53:19 AM6/5/10
to sage-...@googlegroups.com
On Fri, Jun 04, 2010 at 09:44:11AM -0400, Jason Bandlow wrote:
> Thanks Simon and Florent,
>
> This is now http://trac.sagemath.org/sage_trac/ticket/9138 .

Thanks. I renamed this ticket to "Categories for polynomial rings",
following all the other "Categories for ..." tickets.

Polynomial rings should eventually be in GradedAlgebrasWithBasis and
IntegralDomains / EuclideanDomains (depending on the number of
variables); maybe even GradedHopfAlgebrasWithBasis. As a first step,
putting them in IntegralDomains would be good.

That's a good occasion to learn about categories, and with the other
tickets of the same nature (e.g. #8576), there are examples to look at
to see what needs to be done (most likely very little). See:

http://trac.sagemath.org/sage_trac/wiki/CategoriesRoadMap

Cheers,
Nicolas
--
Nicolas M. Thi�ry "Isil" <nth...@users.sf.net>
http://Nicolas.Thiery.name/

Reply all
Reply to author
Forward
0 new messages