Skip to content

Commit d541ce3

Browse files
committed
fixed merge
2 parents e5a4bfa + 38ec21a commit d541ce3

File tree

1 file changed

+311
-0
lines changed

1 file changed

+311
-0
lines changed

02_Speeding_Python.ipynb

Lines changed: 311 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,32 @@
7373
"* http://nbviewer.ipython.org/urls/raw.github.com/pyhpc/pyhpc-tutorial/sahpc2012/02_Speeding_Python.ipynb"
7474
]
7575
},
76+
{
77+
"cell_type": "markdown",
78+
"metadata": {},
79+
"source": [
80+
"--- \n",
81+
"\n",
82+
"## Using the Texas Advanced Computing Center IPython Notebooks\n",
83+
"\n",
84+
"You will need a modern web browser to interact with the TACC nodes, there are no other requirements.\n",
85+
"\n",
86+
"### TACC IPython Notebooks\n",
87+
"* http://pyhpc01.tacc.utexas.edu/\n",
88+
"* http://pyhpc02.tacc.utexas.edu/\n",
89+
"* http://pyhpc03.tacc.utexas.edu/\n",
90+
"* http://pyhpc04.tacc.utexas.edu/\n",
91+
"* http://pyhpc05.tacc.utexas.edu/\n",
92+
"* http://pyhpc06.tacc.utexas.edu/\n",
93+
"* http://pyhpc07.tacc.utexas.edu/\n",
94+
"* http://pyhpc08.tacc.utexas.edu/\n",
95+
"* http://pyhpc09.tacc.utexas.edu/\n",
96+
"* http://pyhpc10.tacc.utexas.edu/\n",
97+
"\n",
98+
"The TACC nodes will not be available after this workshop, please contact the presenters for more permanent hosting solutions."
99+
>>>>>>> 38ec21a86dc8d57019e5eace136ec25ee9b84824
100+
]
101+
},
76102
{
77103
"cell_type": "markdown",
78104
"metadata": {},
@@ -409,6 +435,291 @@
409435
],
410436
"prompt_number": 1
411437
},
438+
{
439+
"cell_type": "code",
440+
"collapsed": false,
441+
"input": [
442+
"# The below command starts pylab inline mode, which simplifies syntax for many common \n",
443+
"# scientific computing commands. All commands starting with % are IPython extensions.\n",
444+
"%pylab inline\n",
445+
"\n",
446+
"import numpy as np\n",
447+
"import scipy as sp\n",
448+
"\n",
449+
"# The following two lines of code load the slideshow extension and start it,\n",
450+
"# you only need to run these if you are writing or running your own slideshow\n",
451+
"\n",
452+
"%load_ext slidemode\n",
453+
"%slideshow_mode"
454+
],
455+
"language": "python",
456+
"metadata": {},
457+
"outputs": [
458+
{
459+
"output_type": "stream",
460+
"stream": "stdout",
461+
"text": [
462+
"\n",
463+
"Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].\n",
464+
"For more information, type 'help(pylab)'.\n"
465+
]
466+
},
467+
{
468+
"javascript": [
469+
"\n",
470+
"var bind_remote = function(selector){\n",
471+
" var cc = $('<input/>')\n",
472+
" .attr('id','azerty')\n",
473+
" .fadeTo(0.2,0)\n",
474+
" .keydown(\n",
475+
" function(event){\n",
476+
" if(event.which == IPython.utils.keycodes.LEFT_ARROW){\n",
477+
" console.log('go left');\n",
478+
" IPython.slideshow.prev();\n",
479+
" }\n",
480+
" else if(event.which == IPython.utils.keycodes.RIGHT_ARROW){\n",
481+
" console.log('go right')\n",
482+
" IPython.slideshow.next(); \n",
483+
" }\n",
484+
" event.preventDefault();\n",
485+
" return false;\n",
486+
" })\n",
487+
" .focusin(function(){$('#qwerty').button('option','label','Slide Control Enabled')})\n",
488+
" .focusout(function(){$('#qwerty').button('option','label','Enable Slide Control')})\n",
489+
" \n",
490+
" var dd = $('<div/>')\n",
491+
" .attr('id','qwerty')\n",
492+
" .button({label:'Enable Slide Control'})\n",
493+
" .attr('style','float:right')\n",
494+
" .click(\n",
495+
" function(){\n",
496+
" $('#azerty').focus();\n",
497+
" console.log('...');\n",
498+
" })\n",
499+
" .keydown(\n",
500+
" function(event){\n",
501+
" console.log('event append',event);\n",
502+
" event.preventDefault();\n",
503+
" return false;\n",
504+
" })\n",
505+
" var hin = function(){$(selector).fadeTo('slow',1);}\n",
506+
" var hout= function(){$(selector).fadeTo('slow',0.3);} \n",
507+
" $(selector)\n",
508+
" .append(cc)\n",
509+
" .append(dd)\n",
510+
" .fadeTo('slow',0.3)\n",
511+
" .hover(hin,hout)\n",
512+
" \n",
513+
"}\n",
514+
" \n",
515+
"var show_line = function(cell,line_number){\n",
516+
" cell.code_mirror.showLine(cell.code_mirror.getLineHandle(line_number-1)) }\n",
517+
"\n",
518+
" IPython = (function(IPython) {\n",
519+
" \n",
520+
" var Presentation = function(){\n",
521+
" this.ccell = 0;\n",
522+
" }\n",
523+
"\n",
524+
" var is_marked_cell = function(cell){\n",
525+
" return (cell.code_mirror.getValue().match(/(\\n)?(<!--|#)?====(-->)?(\\n)?/) != null)\n",
526+
" }\n",
527+
" Presentation.prototype.create_toolbar = function(){\n",
528+
" var pt = $('<div/>').attr('id','toolbar_present').addClass('toolbar');\n",
529+
" var that = this;\n",
530+
" this.avc = $('<div/>').button({label:that.eta()});\n",
531+
" pt.append(this.avc);\n",
532+
"\n",
533+
" $('#toolbar').after(pt);\n",
534+
" var ptoolbar = new IPython.ToolBar('#toolbar_present');\n",
535+
" IPython.ptoolbar = ptoolbar;\n",
536+
" ptoolbar.addButtonsGroup([{label:'Stop', icon:'ui-icon-stop', callback:function(){that.stop()}}])\n",
537+
" ptoolbar.addButtonsGroup([\n",
538+
" {label:'Restart from 0', icon:'ui-icon-arrowthickstop-1-w', callback:function(){that.stop(); that.restart(); that.start()}}\n",
539+
" ])\n",
540+
" ptoolbar.addButtonsGroup([\n",
541+
" {label:'Prev Slide', icon:'ui-icon-seek-prev', callback:function(){that.prev_group()}},\n",
542+
" {label:'Next Slide', icon:'ui-icon-seek-next', callback:function(){that.next_group()}},\n",
543+
" ])\n",
544+
" ptoolbar.addButtonsGroup([\n",
545+
" {label:'Step Next', icon:'ui-icon-play', callback:function(){that.next()}}\n",
546+
" ])\n",
547+
" bind_remote('#toolbar_present');\n",
548+
"\n",
549+
" }\n",
550+
"\n",
551+
" Presentation.prototype.remove_toolbar = function(){\n",
552+
" $('#toolbar_present').remove();\n",
553+
" }\n",
554+
"\n",
555+
" Presentation.prototype.ngroups = function(){\n",
556+
" var cells = IPython.notebook.get_cells();\n",
557+
" var cnt =0\n",
558+
" for( var i=0; i< cells.length;i++)\n",
559+
" if(is_marked_cell(cells[i])) cnt++;\n",
560+
" return cnt\n",
561+
" }\n",
562+
"\n",
563+
" Presentation.prototype.cgroups = function(){\n",
564+
" var cells = IPython.notebook.get_cells();\n",
565+
" var cnt =0\n",
566+
" for( var i=0; i<= this.ccell ;i++)\n",
567+
" if(is_marked_cell(cells[i])) cnt++;\n",
568+
" return cnt\n",
569+
" }\n",
570+
"\n",
571+
" Presentation.prototype.eta = function(){\n",
572+
" return this.cgroups()+'/'+this.ngroups()\n",
573+
" }\n",
574+
"\n",
575+
" Presentation.prototype.next_marked_cell_n = function()\n",
576+
" {\n",
577+
" for(var i=this.ccell+1; i< $('.cell').length; i++)\n",
578+
" {\n",
579+
" if(is_marked_cell(IPython.notebook.get_cell(i)))\n",
580+
" { return i; }\n",
581+
" }\n",
582+
" return null;\n",
583+
" }\n",
584+
"\n",
585+
" Presentation.prototype.prev_marked_cell_n = function()\n",
586+
" {\n",
587+
" for(var i=this.ccell-1; i> 0; i--)\n",
588+
" {\n",
589+
" if(is_marked_cell(IPython.notebook.get_cell(i))){\n",
590+
" return i\n",
591+
" }\n",
592+
" }\n",
593+
" return 0;\n",
594+
" }\n",
595+
"\n",
596+
" Presentation.prototype.start = function(){\n",
597+
" this.restart();\n",
598+
" this.resume();\n",
599+
" }\n",
600+
"\n",
601+
" Presentation.prototype.restart = function(){\n",
602+
" this.ccell = 0;\n",
603+
" $(this.avc).remove();\n",
604+
" delete this.avc;\n",
605+
" }\n",
606+
"\n",
607+
" Presentation.prototype.resume = function(){\n",
608+
" this.create_toolbar();\n",
609+
" $('#menubar, #pager_splitter, #pager, #header,#toolbar').addClass('pmode');\n",
610+
" $('.cell').fadeOut();\n",
611+
" if(this.current_is_marked()){\n",
612+
" $('.cell:nth('+this.ccell+')').fadeIn();\n",
613+
" } else {\n",
614+
" for( var i=this.prev_marked_cell_n() ; i<= this.ccell; i++){\n",
615+
" $('.cell:nth('+i+')').fadeIn();\n",
616+
" }\n",
617+
" }\n",
618+
" var that=this;\n",
619+
" if(this.avc != undefined)\n",
620+
" $(this.avc).button('option','label',that.eta())\n",
621+
" return this;\n",
622+
" }\n",
623+
"\n",
624+
" Presentation.prototype.stop = function(){\n",
625+
" $('.cell').fadeIn();\n",
626+
" $('.pmode').removeClass('pmode');\n",
627+
" $('div#notebook').removeClass('pove');\n",
628+
" this.remove_toolbar();\n",
629+
" }\n",
630+
"\n",
631+
" Presentation.prototype.next = function(){\n",
632+
" this.ccell = this.ccell+1;\n",
633+
" var that = this;\n",
634+
" if(this.ccell >= $('.cell').length ){\n",
635+
" this.restart();\n",
636+
" this.stop();\n",
637+
" return;\n",
638+
" }\n",
639+
" var nnext = this.ccell;\n",
640+
" var ncell = IPython.notebook.get_cell(nnext)\n",
641+
"\n",
642+
" if(is_marked_cell(ncell)){\n",
643+
" $('.cell').fadeOut(500);\n",
644+
" setTimeout(function(){$('.cell:nth('+nnext+')').fadeIn(500)},600);\n",
645+
" } else {\n",
646+
" setTimeout(function(){$('.cell:nth('+nnext+')').fadeIn(500)},0);\n",
647+
" }\n",
648+
" $(this.avc).button('option','label',that.eta())\n",
649+
" return this;\n",
650+
" }\n",
651+
"\n",
652+
" Presentation.prototype.next_group = function(){\n",
653+
" this.ccell = this.next_marked_cell_n();\n",
654+
" var that = this;\n",
655+
" $('.cell').fadeOut(500);\n",
656+
" setTimeout(function(){\n",
657+
" $('.cell:nth('+that.ccell+')').fadeIn(500)\n",
658+
" },600);\n",
659+
" $(this.avc).button('option','label',that.eta())\n",
660+
" }\n",
661+
"\n",
662+
" Presentation.prototype.prev_group = function(){\n",
663+
" this.ccell = this.prev_marked_cell_n();\n",
664+
" var that = this\n",
665+
" $('.cell').fadeOut(500);\n",
666+
" setTimeout(function(){$('.cell:nth('+that.ccell+')').fadeIn(500)},600);\n",
667+
" $(this.avc).button('option','label',that.eta())\n",
668+
" }\n",
669+
"\n",
670+
" Presentation.prototype.is_n_marked = function(n){\n",
671+
" return is_marked_cell(IPython.notebook.get_cell(n))\n",
672+
" }\n",
673+
"\n",
674+
" Presentation.prototype.current_is_marked = function(n){\n",
675+
" return is_marked_cell(IPython.notebook.get_cell(this.ccell));\n",
676+
" }\n",
677+
"\n",
678+
" Presentation.prototype.prev = function(){\n",
679+
" if(is_marked_cell(IPython.notebook.get_cell(this.ccell))){\n",
680+
" var pmcell = this.prev_marked_cell_n();\n",
681+
" $('.cell').fadeOut(500);\n",
682+
" for( var i=pmcell; i< this.ccell ; i++ ){\n",
683+
" (function(val){\n",
684+
" return function(){\n",
685+
" setTimeout( function(){\n",
686+
" $('.cell:nth('+val+')').fadeIn(500)\n",
687+
" },600);\n",
688+
" }\n",
689+
" })(i)();\n",
690+
" }\n",
691+
" } else {\n",
692+
" $('.cell:nth('+this.ccell+')').fadeOut(500);\n",
693+
" }\n",
694+
" this.ccell = this.ccell -1;\n",
695+
" return this;\n",
696+
" }\n",
697+
"\n",
698+
" IPython.Presentation = Presentation;\n",
699+
" return IPython;\n",
700+
"\n",
701+
" })(IPython);\n",
702+
"\n",
703+
" $('body').append($('<style/>').text('.pmode{ display: none !important }'));\n",
704+
" IPython.slideshow = new IPython.Presentation();\n",
705+
"\n",
706+
" var sid = 'start_pmode'\n",
707+
" if(($('#'+sid)).length == 0) {\n",
708+
" IPython.toolbar.addButtonsGroup([\n",
709+
" {'label' :'Start Slideshow',\n",
710+
" 'icon' :'ui-icon-image',\n",
711+
" 'callback':function(){IPython.slideshow.resume()},'id':sid},\n",
712+
" ])\n",
713+
" }\n"
714+
],
715+
"output_type": "display_data",
716+
"text": [
717+
"<IPython.core.display.Javascript at 0x2b255d0>"
718+
]
719+
}
720+
],
721+
"prompt_number": 1
722+
},
412723
{
413724
"cell_type": "markdown",
414725
"metadata": {},

0 commit comments

Comments
 (0)