First time here? Check out the FAQ!

Ask Your Question
4

Error with rational input in IntegerVectors

asked 4 years ago

Johannes Schmitt gravatar image

updated 2 years ago

tmonteil gravatar image

I discovered 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.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
3

answered 4 years ago

vdelecroix gravatar image

updated 4 years ago

Indeed. Thanks Johannes for the bug report (and the investigation)! I opened #29524 and proposed a fix there that was positively reviewed by Frédéric Chapoton. Hopefully, it will be in a next release of SageMath (either 9.1 or 9.2).

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 4 years ago

Seen: 256 times

Last updated: Apr 19 '20