This doesn't work for me at all on CoCalc; it gets stuck in an infinite 
loop because of the matrix A. If I move the definition of A into the body 
of the loop, it seems to work. Like so:

@interact
def linear_transformation(theta=slider(0, 2*pi, .1), r=slider(0.1, 2, .1, 
default=1)):
    A=matrix([[1,-1],[-1,1/2]])
    v=vector([r*cos(theta), r*sin(theta)])
    w = A*v
    circles = sum([circle((0,0), radius=i, color='black') for i in [1..2]])
    pretty_print(html("$%s %s=%s$"%tuple(map(latex, [A, v.column().n(4), 
w.column().n(4)]))))
    show(v.plot(color='red')+w.plot(color='blue')+circles,aspect_ratio=1)

I think the problem, at least in CoCalc, is that @interact expects every 
argument to the function to be an interactive device. That may well be the 
problem in sagemath 8.1 too.

On Friday, September 8, 2017 at 9:00:27 AM UTC-5, HG wrote:
>
> https://wiki.sagemath.org/interact/linear_algebra
> @interact
> def linear_transformation(A=matrix([[1,-1],[-1,1/2]]),theta=slider(0, 
> 2*pi, .1), r=slider(0.1, 2, .1, default=1)):
>     v=vector([r*cos(theta), r*sin(theta)])
>     w = A*v
>     circles = sum([circle((0,0), radius=i, color='black') for i in [1..2]])
>     pretty_print(html("$%s %s=%s$"%tuple(map(latex, [A, v.column().n(4), 
> w.column().n(4)]))))
>     show(v.plot(color='red')+w.plot(color='blue')+circles,aspect_ratio=1)
>
> I got this error in sagemath 8.1(beta4)
>
> Any help ?
>
>        Traceback (most recent call 
> last)/home/pi/sage/local/lib/python2.7/site-packages/ipywidgets/widgets/interaction.pyc
>  in update(self, *args)    215                     value = 
> widget.get_interact_value()    216                     
> self.kwargs[widget._kwarg] = value--> 217                 self.result = 
> self.f(**self.kwargs)    218                 if self.auto_display and 
> self.result is not None:    219                     display(self.result)
> <ipython-input-3-082d256f4933> in linear_transformation(A, theta, r)      4   
>   w = A*v      5     circles = sum([circle((Integer(0),Integer(0)), radius=i, 
> color='black') for i in 
> (ellipsis_range(Integer(1),Ellipsis,Integer(2)))])----> 6     
> pretty_print(html("$%s %s=%s$"%tuple(map(latex, [A, v.column().n(Integer(4)), 
> w.column().n(Integer(4))]))))      7     
> show(v.plot(color='red')+w.plot(color='blue')+circles,aspect_ratio=Integer(1))
> /home/pi/sage/src/sage/structure/element.pyx in 
> sage.structure.element.Element.__getattr__ 
> (/home/pi/sage/src/build/cythonized/sage/structure/element.c:4286)()    477   
>           AttributeError: 'LeftZeroSemigroup_with_category.element_class' 
> object has no attribute 'blah_blah'    478         """--> 479         return 
> self.getattr_from_category(name)    480     481     cdef 
> getattr_from_category(self, name):
> /home/pi/sage/src/sage/structure/element.pyx in 
> sage.structure.element.Element.getattr_from_category 
> (/home/pi/sage/src/build/cythonized/sage/structure/element.c:4395)()    490   
>       else:    491             cls = P._abstract_element_class--> 492         
> return getattr_from_other_class(self, cls, name)    493     494     def 
> __dir__(self):
> /home/pi/sage/src/sage/cpython/getattr.pyx in 
> sage.cpython.getattr.getattr_from_other_class 
> (/home/pi/sage/src/build/cythonized/sage/cpython/getattr.c:1822)()    252     
>     dummy_error_message.cls = type(self)    253         
> dummy_error_message.name = name--> 254         raise dummy_attribute_error    
> 255     attribute = <object>attr    256     # Check for a descriptor (__get__ 
> in Python)
> AttributeError: 'sage.rings.real_mpfr.RealNumber' object has no attribute 
> 'column'
>
>
> ​
>
>

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

Reply via email to