Ask Your Question
1

interact variable print formatting

asked 2011-10-10 02:59:36 +0100

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 22:54:19 +0100 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2011-10-10 06:53:04 +0100

Jason Grout gravatar image

updated 2011-10-10 07:31:36 +0100

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 15:55:11 +0100 )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-10 02:59:36 +0100

Seen: 2,062 times

Last updated: Oct 10 '11