Opened 15 months ago
Closed 15 months ago
#29524 closed defect (fixed)
bug with rational input in IntegerVectors
Reported by:  vdelecroix  Owned by:  

Priority:  major  Milestone:  sage9.1 
Component:  combinatorics  Keywords:  
Cc:  Merged in:  
Authors:  Vincent Delecroix  Reviewers:  Frédéric Chapoton 
Report Upstream:  N/A  Work issues:  
Branch:  f189063 (Commits, GitHub, GitLab)  Commit:  f18906328a305e3ae29819694ea21c06e010f8ec 
Dependencies:  Stopgaps: 
Description (last modified by )
As reported on ask, we have the following unexpected behavior of IntegerVectors:
sage: IntegerVectors(2,3).list() [[2, 0, 0], [1, 1, 0], [1, 0, 1], [0, 2, 0], [0, 1, 1], [0, 0, 2]] sage: IntegerVectors(2,3/1).list() [[2, 0, 0], [1, 1, 0]]
The relevant code block in the implementation of IntegerVectors seems to be the following:
try: return IntegerVectors_nnondescents(n, tuple(k)) except TypeError: pass return IntegerVectors_nk(n, k)
For k=3/1 one has that tuple(k) does not give a TypeError (as opposed to tuple(3)) and thus the code never tries to interpret k as an integer.
sage: tuple(3/1) (3,) sage: tuple(3)  TypeError Traceback (most recent call last) <ipythoninput235e4067a6e17> in <module>() > 1 tuple(Integer(3)) TypeError: 'sage.rings.integer.Integer' object is not iterable
Change History (8)
comment:1 Changed 15 months ago by
 Description modified (diff)
comment:2 Changed 15 months ago by
 Branch set to public/29524
 Commit set to cd6ba09b1134ed211b6388ce6ae70c0426bcd059
 Status changed from new to needs_review
comment:3 Changed 15 months ago by
 Commit changed from cd6ba09b1134ed211b6388ce6ae70c0426bcd059 to f18906328a305e3ae29819694ea21c06e010f8ec
Branch pushed to git repo; I updated commit sha1. New commits:
f189063  fix division in tableau.py

comment:4 followup: ↓ 5 Changed 15 months ago by
what is this "numbers" module ? why is this better than "k in ZZ" ?
comment:5 in reply to: ↑ 4 Changed 15 months ago by
Replying to chapoton:
what is this "numbers" module ?
This is standard Python PEP 3141 see also the documentation here.
why is this better than "k in ZZ" ?
I never said it was better. But it is certainly more Pythonic.
comment:6 Changed 15 months ago by
 Reviewers set to Frédéric Chapoton
 Status changed from needs_review to positive_review
ok, then
comment:7 Changed 15 months ago by
Merci.
comment:8 Changed 15 months ago by
 Branch changed from public/29524 to f18906328a305e3ae29819694ea21c06e010f8ec
 Resolution set to fixed
 Status changed from positive_review to closed
New commits:
29524: more care with input of IntegerVectors