ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 17 Apr 2020 18:26:59 +0200Error with rational input in IntegerVectorshttps://ask.sagemath.org/question/50814/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.Johannes SchmittFri, 17 Apr 2020 18:26:59 +0200https://ask.sagemath.org/question/50814/