Opened 4 years ago

Last modified 3 years ago

#18400 new defect

Maximum recursion depth error when listing points of a projective space

Reported by: vdelecroix Owned by:
Priority: major Milestone: sage-6.7
Component: algebraic geometry Keywords:
Cc: ncohen Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: #18290 Stopgaps:

Description

sage: P = ProjectiveSpace(2,GF(2))
sage: P.point_set().list()
Traceback (most recent call last):
...
RuntimeError: maximum recursion depth exceeded in __instancecheck__

Change History (13)

comment:1 Changed 4 years ago by vdelecroix

  • Dependencies set to #18290

comment:2 Changed 4 years ago by vdelecroix

Though, the following works

sage: P.point_set().points()
[(0 : 0 : 1),
 (0 : 1 : 0),
 (0 : 1 : 1),
 (0 : 2 : 1),
 (1 : 0 : 0),
 (1 : 0 : 1),
 (1 : 1 : 0),
 (1 : 1 : 1),
 (1 : 2 : 1),
 (2 : 0 : 1),
 (2 : 1 : 0),
 (2 : 1 : 1),
 (2 : 2 : 1)]

comment:3 Changed 4 years ago by ncohen

Also:

sage: len(ProjectiveSpace(2,GF(2)))
...
AttributeError: 'ProjectiveSpace_finite_field_with_category' object has no attribute 'list'

comment:4 Changed 4 years ago by ncohen

And

sage: len(ProjectiveSpace(2,GF(2)).point_set())
...
RuntimeError: maximum recursion depth exceeded while calling a Python object

comment:5 Changed 4 years ago by ncohen

apparently list() calls len, and len calls list. I do not see anything wrong with the design.

comment:6 Changed 4 years ago by vdelecroix

The two examples in comment:3 and comment:4 are not exactly wrong in the same way. In algebraic geometry, a scheme is not a set. And indeed

sage: P = ProjectiveSapce(2,GF(2))
sage: P in Sets()
False
sage: P.point_set() in Sets()
True

I do not understand why there is a __len__ implemented there! It is inherited from Parent as

def __len__(self):
    return len(self.list())

Haaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

Vincent

comment:7 Changed 4 years ago by ncohen

First, what about removing the .list() function, which returns tuple(self), i.e. a tuple?

comment:8 Changed 4 years ago by ncohen

What about removing .list() from Parent? God knows that I hate both Parent and categories, but given that a Parent is not necessarily a finite set it is not very smart to have it return the cardinality of the set after a full enumeration.

This 'len' should be in FiniteEnumerateSet or whatever it is named nowadays.

comment:9 Changed 4 years ago by vdelecroix

See the 3 years old ticket #12955...

comment:10 follow-up: Changed 4 years ago by ncohen

Oh. Then it is going to be addressed. Fine.

comment:11 in reply to: ↑ 10 Changed 4 years ago by vdelecroix

Replying to ncohen:

Oh. Then it is going to be addressed.

Some people thinks that opening a ticket solves an issue... I am worried by the "it is going to" which is a date between now and never (though the bound is strict on the right hand side).

comment:12 Changed 4 years ago by ncohen

Yeah. And the people who think that just got millions from Europe.

comment:13 Changed 3 years ago by pbruin

I just ran into this bug:

sage: P.<x,y> = ProjectiveSpace(1, QQ)
sage: Q = P.subscheme(x - y)
sage: S = Q.point_set()
sage: S.points()
[(1 : 1)]
sage: S.list()
Traceback (most recent call last):
...
RuntimeError: maximum recursion depth exceeded in __instancecheck__

The easiest way to solve this is to make list() an alias for points() in sage.schemes.projective.projective_homset.SchemeHomset_points_projective_field. Alternatively we could implement __iter__() in this class and make points() a wrapper around that.

Note: See TracTickets for help on using tickets.