1 | initial version |
I'd say this is a feature. This is what these routines basically translate to:
sage: c0.op_list()
[('load_arg', 0), ('load_const', 2.00000000000000), 'mul', 'return']
sage: c1.op_list()
[('load_const', 0.000000000000000), 'return']
As you can see, c0 translates to multiplying the argument by 2, but c1 translates to returning the constant 0.00: so no chance for np.array to distribute. What you'd basically want is for c0 to multiply its argument by 0.
For the system to do something more intelligent, you'd have to give fast_callable
more information about the domain and codomain of the map you'd like to construct. I'm not so sure that's implemented, though.
In your scenario, it seems the undesired behaviour would only arise for constant expressions, so the easy solution is probably to special case those.