Ask Your Question
1

interact variable print formatting

asked 2011-10-09 19:59:36 -0500

Gökhan Sever gravatar image

Hello,

Say that I have a simple interact function shown as below:

@interact
def myplot(u=(0.5,(0.1,10)), R=(20e-6,(20e-6,1000e-6))):
    #plotting code

Is there a way to print formatting of these variables in the interact zone; 2 digit float for u and e-form for the R. Currently I see both variables as many digit outputs.

Thanks.

edit retag flag offensive close merge delete

Comments

As you pointed out, same question at http://ask.sagemath.org/question/926/decimal-places-in-slider - just for reference for anyone else coming.

kcrisman gravatar imagekcrisman ( 2012-07-10 15:54:19 -0500 )edit

1 answer

Sort by » oldest newest most voted
1

answered 2011-10-09 23:53:04 -0500

Jason Grout gravatar image

updated 2011-10-10 00:31:36 -0500

See the printf-like python string formatting options here. As an example:

sage: "%0.2f"%pi
'3.14'
sage: "%e"%pi
'3.141593e+00'
edit flag offensive delete link more

Comments

Hmm, this doesn't answer what I asked for. http://wiki.sagemath.org/interact/algebra please scroll down to the last example. Floating point sliders are not well formatted. Can we modify them with string formatters?

Gökhan Sever gravatar imageGökhan Sever ( 2011-10-10 08:55:11 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-10-09 19:59:36 -0500

Seen: 755 times

Last updated: Oct 10 '11