First time here? Check out the FAQ!

Ask Your Question
1

interact variable print formatting

asked 13 years ago

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.

Preview: (hide)

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 ( 12 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 13 years ago

Jason Grout gravatar image

updated 13 years ago

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

sage: "%0.2f"%pi
'3.14'
sage: "%e"%pi
'3.141593e+00'
Preview: (hide)
link

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 ( 13 years ago )

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: 13 years ago

Seen: 2,126 times

Last updated: Oct 10 '11