{"id":273759,"date":"2016-02-07T21:23:03","date_gmt":"2016-02-07T18:23:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=273759"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=273759","title":{"rendered":"\u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447 \u0432 IPython Notebook"},"content":{"rendered":"<p>       \u0425\u043e\u0442\u0435\u043b \u0431\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u043c, \u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c. \u041a\u043e\u0433\u0434\u0430 \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0448\u044c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0447\u0430\u0441\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0435, \u043d\u043e \u0434\u043e\u043b\u0433\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: \u00ab\u0441\u043a\u0430\u0447\u0430\u0442\u044c 10 000 \u0443\u0440\u043b\u043e\u0432\u00bb, \u00ab\u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u043d\u0430 2\u0413\u0431, \u0438 \u0447\u0442\u043e-\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u043e\u0439\u00bb, \u00ab\u0440\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u0442\u044c 10 000 html-\u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u044c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438\u00bb. \u0414\u043e\u043b\u0433\u043e \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0437\u0430\u0432\u0438\u0441\u0448\u0438\u0439 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b \u0442\u0440\u0435\u0432\u043e\u0436\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u043b\u0433\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0433\u0435\u043d\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434: <\/p>\n<pre><code class=\"python\">def log_progress(sequence, every=10):     for index, item in enumerate(sequence):         if index % every == 0:             print &gt;&gt;sys.stderr, index,         yield item <\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/41d\/b19\/857\/41db19857a664e74b03d763e7243f0c3.gif\"\/><\/p>\n<p>  \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u0430, \u0431\u043e\u043b\u044c\u0448\u0435 \u0433\u043e\u0434\u0430 \u043e\u043d\u0430 \u043a\u043e\u0447\u0435\u0432\u0430\u043b\u0430 \u0443 \u043c\u0435\u043d\u044f \u0438\u0437 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u0437\u0430\u0434\u0430\u0447\u0443. \u041d\u043e \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0437\u0430\u043c\u0435\u0442\u0438\u043b \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u043f\u043e\u0441\u0442\u0430\u0432\u043a\u0435 Jupyter \u0432\u0438\u0434\u0436\u0435\u0442 IntProgress \u0438 \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u043f\u043e\u0440\u0430 \u0447\u0442\u043e-\u0442\u043e \u043c\u0435\u043d\u044f\u0442\u044c:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/fde\/8d9\/be6\/fde8d9be6e4f4cae9bc1c169bfd6a688.gif\"\/><br \/>  <a name=\"habracut\"><\/a><br \/>  \u0423 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 stderr \u0435\u0441\u0442\u044c \u0442\u0440\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b:<\/p>\n<ol>\n<li>\u042d\u0442\u043e \u043d\u0435\u043a\u0440\u0430\u0441\u0438\u0432\u043e. \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e.<\/li>\n<li>\u0418\u043d\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u0432\u0437\u0440\u044b\u0432\u0430\u0435\u0442 \u0431\u0443\u0444\u0435\u0440.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/f43\/4c5\/b03\/f434c5b030974ad4b46d20c9b4790c9d.gif\"\/><\/li>\n<li>\u0418\u043d\u043e\u0433\u0434\u0430 \u043a\u0442\u043e-\u0442\u043e \u0435\u0449\u0451 \u043f\u0438\u0448\u0435\u0442 \u0432 stderr \u0438\u043b\u0438 stdout.<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/318\/029\/310\/31802931010d47c081560377182a6681.gif\"\/><\/li>\n<\/ol>\n<p>  \u041a\u0430\u043a \u0438 \u043c\u043d\u043e\u0433\u0438\u0435 \u043b\u044e\u0434\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u044f \u0444\u0430\u043d\u0430\u0442 Jupyter. \u0411\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u0440\u043e\u0432\u043e\u0436\u0443 \u0442\u0430\u043c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0433\u0443 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435, \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0435 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u0440\u0435\u0434\u0430\u043c\u0438, \u0440\u0435\u0448\u0435\u043d\u0438\u0435: <\/p>\n<pre><code class=\"python\">def log_progress(sequence, every=10):     from ipywidgets import IntProgress     from IPython.display import display      progress = IntProgress(min=0, max=len(sequence), value=0)     display(progress)          for index, record in enumerate(sequence):         if index % every == 0:             progress.value = index         yield record <\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/c67\/996\/ac5\/c67996ac58024bfa9929b30e3ae56e8f.gif\"\/><\/p>\n<p>  \u0412\u0441\u0451 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0447\u0451\u0442\u0447\u0438\u043a \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0435 \u0432 stderr, \u0430 \u0432 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u0438\u0434\u0436\u0435\u0442. \u041e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u0443\u0434\u043e\u0431\u043d\u043e. \u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0442\u043e\u0436\u0435 \u043f\u043e\u0434\u0441\u0435\u043b \u043d\u0430 Jupyter, \u044f \u0432\u044b\u043b\u043e\u0436\u0438\u043b \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u043d\u0430 \u0413\u0438\u0442\u0445\u0430\u0431 <a href=\"https:\/\/github.com\/alexanderkuk\/log-progress\">github.com\/alexanderkuk\/log-progress<\/a>. \u041c\u043e\u0434\u0443\u043b\u044c \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043f\u0438\u043f\u0435\u0439\u0441\u0442\u043e\u043c. \u041f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435\u0441\u044c \u043d\u0430 \u0437\u0434\u043e\u0440\u043e\u0432\u044c\u0435.<\/p>\n<p>  \u0423\u043b\u0443\u0447\u0448\u0435\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043a\u0440\u043e\u043c\u0435 \u043f\u043e\u043b\u043e\u0441\u043a\u0438 \u0435\u0449\u0451 \u0438 \u0441\u0447\u0451\u0442\u0447\u0438\u043a. \u0418 \u043c\u0435\u043d\u044f\u0435\u0442 \u0446\u0432\u0435\u0442 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0430\u0441\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0438\u043b\u0438 \u043d\u0435\u0442:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/d7a\/1f5\/9f6\/d7a1f59f61634d63a42b274ba186d1ba.gif\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/1bc\/544\/e8a\/1bc544e8a50b419382d0fc090e087cce.gif\"\/><\/p>\n<p>  \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440\u044b:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/712\/255\/d77\/712255d77fd5473b8113e7bfc1bd852f.gif\"\/><\/p>\n<p>  \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432 \u043e\u0434\u043d\u043e\u0439 \u044f\u0447\u0435\u0439\u043a\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441 \u0431\u0430\u0440\u043e\u0432:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/1b4\/48f\/9a5\/1b448f9a5b74456091eb5b16799c7c3e.gif\"\/><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/95d\/c00\/1df\/95dc001dffb24852999a73ae8129a209.gif\"\/><\/p>\n<p>  \u0418 \u043e\u043d\u0438 \u0434\u0430\u0436\u0435 \u043c\u043e\u0433\u0443\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0440\u0435\u0434\u043e\u0432:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/e64\/69a\/fe5\/e6469afe59ed485c84565a672d24cd50.gif\"\/><\/p>\n<p>  \u041a\u043e\u0440\u043e\u0447\u0435, \u0435\u0449\u0451 \u0440\u0430\u0437 \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043a\u043e\u0434 <a href=\"https:\/\/github.com\/alexanderkuk\/log-progress\">github.com\/alexanderkuk\/log-progress<\/a>.               <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/276725\/\"> https:\/\/habrahabr.ru\/post\/276725\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0425\u043e\u0442\u0435\u043b \u0431\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u043c, \u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c. \u041a\u043e\u0433\u0434\u0430 \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0448\u044c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0447\u0430\u0441\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u044b\u0435, \u043d\u043e \u0434\u043e\u043b\u0433\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: \u00ab\u0441\u043a\u0430\u0447\u0430\u0442\u044c 10 000 \u0443\u0440\u043b\u043e\u0432\u00bb, \u00ab\u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u043d\u0430 2\u0413\u0431, \u0438 \u0447\u0442\u043e-\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u043e\u0439\u00bb, \u00ab\u0440\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u0442\u044c 10 000 html-\u0444\u0430\u0439\u043b\u043e\u0432 \u0438 \u0434\u043e\u0441\u0442\u0430\u0442\u044c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438\u00bb. \u0414\u043e\u043b\u0433\u043e \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0437\u0430\u0432\u0438\u0441\u0448\u0438\u0439 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b \u0442\u0440\u0435\u0432\u043e\u0436\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u043b\u0433\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0433\u0435\u043d\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434: <\/p>\n<pre><code class=\"python\">def log_progress(sequence, every=10):     for index, item in enumerate(sequence):         if index % every == 0:             print &gt;&gt;sys.stderr, index,         yield item <\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/41d\/b19\/857\/41db19857a664e74b03d763e7243f0c3.gif\"\/><\/p>\n<p>  \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u0430, \u0431\u043e\u043b\u044c\u0448\u0435 \u0433\u043e\u0434\u0430 \u043e\u043d\u0430 \u043a\u043e\u0447\u0435\u0432\u0430\u043b\u0430 \u0443 \u043c\u0435\u043d\u044f \u0438\u0437 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u0437\u0430\u0434\u0430\u0447\u0443. \u041d\u043e \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0437\u0430\u043c\u0435\u0442\u0438\u043b \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u043f\u043e\u0441\u0442\u0430\u0432\u043a\u0435 Jupyter \u0432\u0438\u0434\u0436\u0435\u0442 IntProgress \u0438 \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u043f\u043e\u0440\u0430 \u0447\u0442\u043e-\u0442\u043e \u043c\u0435\u043d\u044f\u0442\u044c:<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/fde\/8d9\/be6\/fde8d9be6e4f4cae9bc1c169bfd6a688.gif\"\/>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-273759","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/273759","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=273759"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/273759\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=273759"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=273759"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=273759"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}