Now my boss went for a simple spreadsheet solution. something like:
Original Values | (hidden cell function) | |
jtag_hi | 640000 | |
jtag_lo | 640000 | |
jtag_period | 1280000 | =b1+b2 |
jtag_idle | 500 | |
New Values | ||
jtag_hi | 1300 | |
jtag_lo | 100 | |
jtag_period | 1400 | =b7+b8 |
jtag_idle | 457000 | =b3/b9*b4 |
I got thinking about the immediate use of the spreadsheet and thought why would I not do this in Python?
The idea is to show how a result is calculated ideally to be cut and pasted into a larger document or printed out.
In Ipython I would get the following log:
@pc[PC1]|2> jtag_lo=640000
@pc[PC1]|3> jtag_hi=640000
@pc[PC1]|4> jtag_period=jtag_lo+jtag_hi
@pc[PC1]|5> jtag_idle=500
@pc[PC1]|6> jtag_lo2=1300
@pc[PC1]|7> jtag_hi2=100
@pc[PC1]|8> jtag_period2=jtag_lo2+jtag_hi2
@pc[PC1]|9> jtag_idle2=jtag_idle*jtag_period/jtag_period2
@pc[PC1]|10> print jtag_idle2
457142
@pc[PC1]|11>
@pc[PC1]|3> jtag_hi=640000
@pc[PC1]|4> jtag_period=jtag_lo+jtag_hi
@pc[PC1]|5> jtag_idle=500
@pc[PC1]|6> jtag_lo2=1300
@pc[PC1]|7> jtag_hi2=100
@pc[PC1]|8> jtag_period2=jtag_lo2+jtag_hi2
@pc[PC1]|9> jtag_idle2=jtag_idle*jtag_period/jtag_period2
@pc[PC1]|10> print jtag_idle2
457142
@pc[PC1]|11>
Notice how although the functions are shown, the intermediate answers are not, requiring the print at the end to display the final answer.
What would be ideal is if Ipython had a mode where it would show the value assigned to any name automatically, (when a simple
This mode should give the following type of output at the command line:
@pc[PC1]|2> jtag_lo=640000
= 640000
@pc[PC1]|3> jtag_hi=640000
= 640000
@pc[PC1]|4> jtag_period=jtag_lo+jtag_hi
= 1280000
@pc[PC1]|5> jtag_idle=500
= 500
@pc[PC1]|6> jtag_lo2=1300
= 1300
@pc[PC1]|7> jtag_hi2=100
= 100
@pc[PC1]|8> jtag_period2=jtag_lo2+jtag_hi2
= 1400
@pc[PC1]|9> jtag_idle2=jtag_idle*jtag_period/jtag_period2
= 457142
= 640000
@pc[PC1]|3> jtag_hi=640000
= 640000
@pc[PC1]|4> jtag_period=jtag_lo+jtag_hi
= 1280000
@pc[PC1]|5> jtag_idle=500
= 500
@pc[PC1]|6> jtag_lo2=1300
= 1300
@pc[PC1]|7> jtag_hi2=100
= 100
@pc[PC1]|8> jtag_period2=jtag_lo2+jtag_hi2
= 1400
@pc[PC1]|9> jtag_idle2=jtag_idle*jtag_period/jtag_period2
= 457142
Finally, if Ipython allowed me to edit a line, e.g. line five to set jtag_idle to 50 , then replay lines 2 to 9 with the edited line 5 and show the new intermediate results, then I would prefer the Ipython solution to the spreadsheet one as I am very familiar with the procedural code and the resultant log, when printed or cut and pasted into a larger document would be both more informative than the spreadsheet (both the calculation and intermediate results would be shown at once); and more succinct (either plain text or simple HTML/RTF versus an embedded spreadsheet or HTML table that would loose the formulae).
This comment has been removed by a blog administrator.
ReplyDeletehttps://gist.github.com/vedgar/d0124366bc1358f77b83
ReplyDelete