This is even a more interesting example:

sage: f(x,y) = x+y
sage: Matrix(2, 2, f)  # Matrix over CallableSymbolicExpressionRing
[(x, y) |--> x + y     (x, y) |--> 0]
[    (x, y) |--> 0 (x, y) |--> x + y]


Here is a proposal (assuming callable(f) is true):

if not isinstance(f, RingElement):
    treat f as function

elif we were called as Matrix(R, ...) with a ring R:
    if f in R:
        return f*identity matrix
    else:
        treat f as function

else:
    deprecation(...)
    return f*identity matrix

--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to