Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Error with rational input in IntegerVectors

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.

Error with rational input in IntegerVectors

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.

Error with rational input in IntegerVectors

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.