Opened 4 years ago

Last modified 4 years ago

#24988 new defect

Refining Steenrod algebra category to enumerated sets breaks some_elements()

Reported by: cnassau Owned by:
Priority: major Milestone: sage-8.2
Component: categories Keywords:
Cc: jhpalmieri Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

The subalgebra of the Steenrod algebra with empty profile happens to be the ground field. When Sage recognizes this, it refines the category to something that implies "EnumeratedSets?". This replaces the implementation of "some_elements" and "an_element", which are subsequently broken:

sage: A=SteenrodAlgebra(2,profile=())
sage: A.some_elements()
[1]
sage: A in Fields()
True
sage: A.some_elements()
<generator object _some_elements_from_iterator at 0x7f385d4f4b90>
sage: list(A.some_elements())
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-5-f6d5b992d1b8> in <module>()
----> 1 list(A.some_elements())

/waste/cn/sage-git/local/lib/python2.7/site-packages/sage/categories/enumerated_sets.pyc in _some_elements_from_iterator(self)
    845             """
    846             nb = 0
--> 847             for i in self:
    848                 yield i
    849                 nb += 1

/waste/cn/sage-git/local/lib/python2.7/site-packages/sage/categories/enumerated_sets.pyc in __iter__(self)
    242                 return self._iterator_from_list()
    243             else:
--> 244                 raise NotImplementedError("iterator called but not implemented")
    245 
    246         def is_empty(self):

NotImplementedError: iterator called but not implemented

Its not clear to me where to assign the blame for this, or how to fix it...

Change History (3)

comment:1 follow-up: Changed 4 years ago by jhpalmieri

Related:

sage: B = SteenrodAlgebra(profile=[])
sage: B in EnumeratedSets()
False
sage: B in Fields()
True
sage: B in EnumeratedSets()
True

Just testing whether something is in Fields shouldn't have such side effects, should it?

comment:2 in reply to: ↑ 1 ; follow-up: Changed 4 years ago by cnassau

Replying to jhpalmieri:

Just testing whether something is in Fields shouldn't have such side effects, should it?

I think the general philosophy (that structures can get refined when more information about them is discovered) is a deliberate design decision and not per se questionable.

The bug seems to be in the assignment

some_elements = _some_elements_from_iterator

in src/sage/categories/enumerated_sets.py. This annihilates any existing implementation, which is a bad thing.

I wonder if one could not just define a regular "some_elements" in that category; whoever wrote that code must have had reasons, not to do it this way, but the reasons are not obvious to me.

comment:3 in reply to: ↑ 2 Changed 4 years ago by cnassau

Replying to cnassau:

I wonder if one could not just define a regular "some_elements" in that category; whoever wrote that code must have had reasons, not to do it this way, but the reasons are not obvious to me.

My analysis is wrong: changing the implementation in src/sage/categories/enumerated_sets.py doesn't change the behaviour. The original "some_elements" comes from sage/categories/sets_cat.py and is rightly hidden by the enumerated_set implementation since this precedes it in the list of base classes.

Note: See TracTickets for help on using tickets.