On a related note, it seems that when an item in the selector is a zip, now that zips are not evaluated lists, then the zip is "used up" in the process of making the selector. Compare the following:
To claim/decide whether something is a bug and/or documentation failure, it would be nice to have some documented behavior... A loooong time ago when I was writing interacts myself, it was indeed quite frustrating to see discrepancies between SageNB and SageMathCell (and then CoCalc too). Documentation for all features also was not available.
With the current situation, I think it is desirable1) not to break things that are working now
2) have consistency with Jupyter/CoCalc
3) follow some documentation (if things are consistent, no need for separate documentation from other systems)
Help in incremental achieving of these goals is surely appreciated - in the form of examples that behave differently as well as pull requests!
sage: @interact | |
... def _(R=selector([ZZ,QQ,GF(17),RDF,RR]), n=(1..10)): | |
... M = random_matrix(R, n) | |
... show(M) | |
... show(matrix_plot(M,cmap='Oranges')) | |
... f = M.charpoly() | |
... print(f) | |
<html>... |
Going back to defaults as tuples - neither CoCalc nor Jupyter allow it and again - interact code in SageMathCell did not change in logic since 2014. So there is no reason to behave differently now...
This one works now without explicit conversion to a list (it is done internally).
This one will take some more tracing. There are checks when something is a list/tuple and then there are checks of elements of such things, both break with iterators. Thank you for uncovering these places!
I've fiddled a bit with automatic controls for different types:I dislike the distinction in behaviour between tuples/lists/generators, especially when it is dependent on length, but tried to keep the logic that presumably used to work at some point.
Namely:- range used to return a list, so I treat it as a list- there was treatment for GeneratorType and 1..10 now returns generator (which is a different thing, not sure if it was the case before), so I treat it the same way as Generator type.
Check the behaviour on this code:@interact
def f(n=range(2,7)):
@interact
def g(a=range(n), b=list(range(n)), c=(0..n), d=tuple(range(n))):
print(a, b, c, d)