#29524 closed defect (fixed)

bug with rational input in IntegerVectors

Reported by: vdelecroix Owned by:
Priority: major Milestone: sage-9.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:

Status badges

Description (last modified by vdelecroix)

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:

        return IntegerVectors_nnondescents(n, tuple(k))
    except TypeError:

    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)
sage: tuple(3)
TypeError                                 Traceback (most recent call last)
<ipython-input-2-35e4067a6e17> 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 vdelecroix

  • Description modified (diff)

comment:2 Changed 15 months ago by vdelecroix

  • Authors set to Vincent Delecroix
  • Branch set to public/29524
  • Commit set to cd6ba09b1134ed211b6388ce6ae70c0426bcd059
  • Status changed from new to needs_review

New commits:

cd6ba0929524: more care with input of IntegerVectors

comment:3 Changed 15 months ago by git

  • Commit changed from cd6ba09b1134ed211b6388ce6ae70c0426bcd059 to f18906328a305e3ae29819694ea21c06e010f8ec

Branch pushed to git repo; I updated commit sha1. New commits:

f189063fix division in tableau.py

comment:4 follow-up: Changed 15 months ago by chapoton

what is this "numbers" module ? why is this better than "k in ZZ" ?

comment:5 in reply to: ↑ 4 Changed 15 months ago by vdelecroix

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 chapoton

  • Reviewers set to Frédéric Chapoton
  • Status changed from needs_review to positive_review

ok, then

comment:7 Changed 15 months ago by vdelecroix


comment:8 Changed 15 months ago by vbraun

  • Branch changed from public/29524 to f18906328a305e3ae29819694ea21c06e010f8ec
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.