##// END OF EJS Templates
clean up ProgressBar class in example notebook...
Hans Meine -
Show More
@@ -204,25 +204,16 b''
204 "collapsed": true,
204 "collapsed": true,
205 "input": [
205 "input": [
206 "import sys, time\n",
206 "import sys, time\n",
207 "try:\n",
208 " from IPython.display import clear_output\n",
209 " have_ipython = True\n",
210 "except ImportError:\n",
211 " have_ipython = False\n",
212 "\n",
207 "\n",
213 "class ProgressBar:\n",
208 "class ProgressBar:\n",
214 " def __init__(self, iterations):\n",
209 " def __init__(self, iterations):\n",
215 " self.iterations = iterations\n",
210 " self.iterations = iterations\n",
216 " self.prog_bar = '[]'\n",
211 " self.prog_bar = '[]'\n",
217 " self.fill_char = '*'\n",
212 " self.fill_char = '*'\n",
218 " self.width = 40\n",
213 " self.width = 50\n",
219 " self.__update_amount(0)\n",
214 " self.__update_amount(0)\n",
220 " if have_ipython:\n",
221 " self.animate = self.animate_ipython\n",
222 " else:\n",
223 " self.animate = self.animate_noipython\n",
224 "\n",
215 "\n",
225 " def animate_ipython(self, iter):\n",
216 " def animate(self, iter):\n",
226 " print '\\r', self,\n",
217 " print '\\r', self,\n",
227 " sys.stdout.flush()\n",
218 " sys.stdout.flush()\n",
228 " self.update_iteration(iter + 1)\n",
219 " self.update_iteration(iter + 1)\n",
@@ -254,19 +245,12 b''
254 "input": [
245 "input": [
255 "p = ProgressBar(1000)\n",
246 "p = ProgressBar(1000)\n",
256 "for i in range(1001):\n",
247 "for i in range(1001):\n",
248 " time.sleep(0.002)\n",
257 " p.animate(i)"
249 " p.animate(i)"
258 ],
250 ],
259 "language": "python",
251 "language": "python",
260 "metadata": {},
252 "metadata": {},
261 "outputs": []
253 "outputs": []
262 },
263 {
264 "cell_type": "code",
265 "collapsed": false,
266 "input": [],
267 "language": "python",
268 "metadata": {},
269 "outputs": []
270 }
254 }
271 ],
255 ],
272 "metadata": {}
256 "metadata": {}
General Comments 0
You need to be logged in to leave comments. Login now