Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maximum recursion depth error when listing points of a projective space #18400

Open
videlec opened this issue May 11, 2015 · 13 comments
Open

Maximum recursion depth error when listing points of a projective space #18400

videlec opened this issue May 11, 2015 · 13 comments

Comments

@videlec
Copy link
Contributor

videlec commented May 11, 2015

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

Depends on #18290

CC: @nathanncohen

Component: algebraic geometry

Issue created by migration from https://trac.sagemath.org/ticket/18400

@videlec videlec added this to the sage-6.7 milestone May 11, 2015
@videlec
Copy link
Contributor Author

videlec commented May 11, 2015

Dependencies: #18290

@videlec
Copy link
Contributor Author

videlec commented May 11, 2015

comment:2

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)]

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented May 11, 2015

comment:3

Also:

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

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented May 11, 2015

comment:4

And

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

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented May 11, 2015

comment:5

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

@videlec
Copy link
Contributor Author

videlec commented May 11, 2015

comment:6

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

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented May 11, 2015

comment:7

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

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented May 11, 2015

comment:8

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.

@videlec
Copy link
Contributor Author

videlec commented May 11, 2015

comment:9

See the 3 years old ticket #12955...

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented May 11, 2015

comment:10

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

@videlec
Copy link
Contributor Author

videlec commented May 11, 2015

comment:11

Replying to @nathanncohen:

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).

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented May 11, 2015

comment:12

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

@pjbruin
Copy link
Contributor

pjbruin commented Nov 4, 2016

comment:13

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.

@mkoeppe mkoeppe removed this from the sage-6.7 milestone Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants