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.Sat, 15 Jul 2017 18:48:12 +0200Problem regarding user input in Sage manifoldshttps://ask.sagemath.org/question/38273/problem-regarding-user-input-in-sage-manifolds/I am unable to take input from user in case of sage manifold,i am working in differentiable manifold.Especially,I am having problem to take input from user in case of vector fields(differentiable manifold)
Any help is appreciatedSat, 15 Jul 2017 10:48:51 +0200https://ask.sagemath.org/question/38273/problem-regarding-user-input-in-sage-manifolds/Comment by vdelecroix for <p>I am unable to take input from user in case of sage manifold,i am working in differentiable manifold.Especially,I am having problem to take input from user in case of vector fields(differentiable manifold)
Any help is appreciated</p>
https://ask.sagemath.org/question/38273/problem-regarding-user-input-in-sage-manifolds/?comment=38276#post-id-38276In order to get help you need:
1. to give details about your operating system and your Sage installation
2. describe precisely your problem
3. provide some code snippetSat, 15 Jul 2017 13:30:55 +0200https://ask.sagemath.org/question/38273/problem-regarding-user-input-in-sage-manifolds/?comment=38276#post-id-38276Comment by Shouvik for <p>I am unable to take input from user in case of sage manifold,i am working in differentiable manifold.Especially,I am having problem to take input from user in case of vector fields(differentiable manifold)
Any help is appreciated</p>
https://ask.sagemath.org/question/38273/problem-regarding-user-input-in-sage-manifolds/?comment=38278#post-id-38278My operating system is windows and i am executing sage software 7.6 using sage manifold appliance (virtual box) My problem is t I am unable to take raw_input from user(just like python) for vector field on a
5 dimensional manifold.
The code snippet is as follows
M = Manifold(5, 'M')
X.<a,b,c,d,e> = M.chart()
v = M.vector_field(name='v')
eU = X.frame()
v[eU,:]=raw_input("enter a value")
print v[0]Sat, 15 Jul 2017 17:09:41 +0200https://ask.sagemath.org/question/38273/problem-regarding-user-input-in-sage-manifolds/?comment=38278#post-id-38278Answer by dan_fulea for <p>I am unable to take input from user in case of sage manifold,i am working in differentiable manifold.Especially,I am having problem to take input from user in case of vector fields(differentiable manifold)
Any help is appreciated</p>
https://ask.sagemath.org/question/38273/problem-regarding-user-input-in-sage-manifolds/?answer=38280#post-id-38280Note that the raw input captures a string from the user - in my case from the sage interpreter:
sage: a = raw_input( "Please enter a number... >" )
Please enter a number... >7
sage: a
'7'
The code has to arrange that the input is parsed correctly. For the posted case an evaluation would be enough, if the user raw input is prepared to be evaluated. Note for this the example:
sage: eval( '17, 5, 22, 196544, -1' )
(17, 5, 22, 196544, -1)
sage: type( _ )
<type 'tuple'>
Slightly changed code:
M = Manifold(5, 'M')
X.<a,b,c,d,e> = M.chart()
v = M.vector_field(name='v')
eU = X.frame()
v[eU,:] = eval( raw_input( "enter five numbers (comma separated) > " ) )
print "eU =", eU
print "v[ eU, : ] =", v[eU,:]
Let's see it it works, code was copy-pasted into the sage interpreter via `%cpaste`:
sage: %cpaste
Pasting code; enter '--' alone on the line to stop or use Ctrl-D.
:M = Manifold(5, 'M')
X.<a,b,c,d,e> = M.chart()
v = M.vector_field(name='v')
eU = X.frame()
v[eU,:] = eval( raw_input( "enter five numbers (comma separated) > " ) )
print "eU =", eU
print "v[ eU, : ] =", v[eU,:]
:::::::
:--
enter five numbers (comma separated) > 17, 5, 22, 196544, -1
eU = Coordinate frame (M, (d/da,d/db,d/dc,d/dd,d/de))
v[ eU, : ] = [17, 5, 22, 196544, -1]
sage:
Sat, 15 Jul 2017 18:07:48 +0200https://ask.sagemath.org/question/38273/problem-regarding-user-input-in-sage-manifolds/?answer=38280#post-id-38280Comment by Shouvik for <p>Note that the raw input captures a string from the user - in my case from the sage interpreter:</p>
<pre><code>sage: a = raw_input( "Please enter a number... >" )
Please enter a number... >7
sage: a
'7'
</code></pre>
<p>The code has to arrange that the input is parsed correctly. For the posted case an evaluation would be enough, if the user raw input is prepared to be evaluated. Note for this the example:</p>
<pre><code>sage: eval( '17, 5, 22, 196544, -1' )
(17, 5, 22, 196544, -1)
sage: type( _ )
<type 'tuple'>
</code></pre>
<p>Slightly changed code:</p>
<pre><code>M = Manifold(5, 'M')
X.<a,b,c,d,e> = M.chart()
v = M.vector_field(name='v')
eU = X.frame()
v[eU,:] = eval( raw_input( "enter five numbers (comma separated) > " ) )
print "eU =", eU
print "v[ eU, : ] =", v[eU,:]
</code></pre>
<p>Let's see it it works, code was copy-pasted into the sage interpreter via <code>%cpaste</code>:</p>
<pre><code>sage: %cpaste
Pasting code; enter '--' alone on the line to stop or use Ctrl-D.
:M = Manifold(5, 'M')
X.<a,b,c,d,e> = M.chart()
v = M.vector_field(name='v')
eU = X.frame()
v[eU,:] = eval( raw_input( "enter five numbers (comma separated) > " ) )
print "eU =", eU
print "v[ eU, : ] =", v[eU,:]
:::::::
:--
enter five numbers (comma separated) > 17, 5, 22, 196544, -1
eU = Coordinate frame (M, (d/da,d/db,d/dc,d/dd,d/de))
v[ eU, : ] = [17, 5, 22, 196544, -1]
sage:
</code></pre>
https://ask.sagemath.org/question/38273/problem-regarding-user-input-in-sage-manifolds/?comment=38281#post-id-38281thank you,its workingSat, 15 Jul 2017 18:48:12 +0200https://ask.sagemath.org/question/38273/problem-regarding-user-input-in-sage-manifolds/?comment=38281#post-id-38281