my_iterator.html 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>image_features_extraction.my_iterator &#8212; Image Features Extraction 1.0.0 documentation</title>
  7. <link rel="stylesheet" href="../../_static/alabaster.css" type="text/css" />
  8. <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  9. <script type="text/javascript">
  10. var DOCUMENTATION_OPTIONS = {
  11. URL_ROOT: '../../',
  12. VERSION: '1.0.0',
  13. COLLAPSE_INDEX: false,
  14. FILE_SUFFIX: '.html',
  15. HAS_SOURCE: true,
  16. SOURCELINK_SUFFIX: '.txt'
  17. };
  18. </script>
  19. <script type="text/javascript" src="../../_static/jquery.js"></script>
  20. <script type="text/javascript" src="../../_static/underscore.js"></script>
  21. <script type="text/javascript" src="../../_static/doctools.js"></script>
  22. <link rel="index" title="Index" href="../../genindex.html" />
  23. <link rel="search" title="Search" href="../../search.html" />
  24. <link rel="stylesheet" href="../../_static/custom.css" type="text/css" />
  25. <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
  26. </head>
  27. <body>
  28. <div class="document">
  29. <div class="documentwrapper">
  30. <div class="bodywrapper">
  31. <div class="body" role="main">
  32. <h1>Source code for image_features_extraction.my_iterator</h1><div class="highlight"><pre>
  33. <span></span><span class="kn">from</span> <span class="nn">abc</span> <span class="k">import</span> <span class="n">ABCMeta</span><span class="p">,</span> <span class="n">abstractmethod</span>
  34. <span class="k">class</span> <span class="nc">my_iterator</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
  35. <span class="sd">&quot;&quot;&quot;</span>
  36. <span class="sd"> abstract class used to implement a collection class</span>
  37. <span class="sd"> &quot;&quot;&quot;</span>
  38. <span class="n">__metaclass__</span> <span class="o">=</span> <span class="n">ABCMeta</span>
  39. <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
  40. <span class="bp">self</span><span class="o">.</span><span class="n">current</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
  41. <span class="bp">self</span><span class="o">.</span><span class="n">__count</span> <span class="o">=</span> <span class="mi">0</span>
  42. <span class="k">def</span> <span class="nf">item</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">i</span><span class="p">):</span>
  43. <span class="sd">&quot;&quot;&quot;</span>
  44. <span class="sd"> item has to be inplemented in the main class</span>
  45. <span class="sd"> &quot;&quot;&quot;</span>
  46. <span class="k">pass</span>
  47. <span class="k">def</span> <span class="nf">count_update</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">count</span><span class="p">):</span>
  48. <span class="bp">self</span><span class="o">.</span><span class="n">__count</span> <span class="o">=</span> <span class="n">count</span>
  49. <span class="k">return</span> <span class="n">count</span>
  50. <span class="k">def</span> <span class="nf">count</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
  51. <span class="sd">&quot;&quot;&quot;</span>
  52. <span class="sd"> returns the number of items</span>
  53. <span class="sd"> &quot;&quot;&quot;</span>
  54. <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">__count</span>
  55. <span class="k">def</span> <span class="nf">__iter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
  56. <span class="sd">&quot;&quot;&quot;</span>
  57. <span class="sd"> Python method to define and call the iterator</span>
  58. <span class="sd"> &quot;&quot;&quot;</span>
  59. <span class="k">return</span> <span class="bp">self</span>
  60. <span class="c1"># used to define the iterator: next element</span>
  61. <span class="k">def</span> <span class="nf">__next__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
  62. <span class="sd">&quot;&quot;&quot;</span>
  63. <span class="sd"> Python method to calls the iterator next element</span>
  64. <span class="sd"> &quot;&quot;&quot;</span>
  65. <span class="bp">self</span><span class="o">.</span><span class="n">current</span> <span class="o">+=</span> <span class="mi">1</span>
  66. <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">current</span> <span class="o">&gt;=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__count</span><span class="p">:</span>
  67. <span class="bp">self</span><span class="o">.</span><span class="n">current</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
  68. <span class="k">raise</span> <span class="ne">StopIteration</span>
  69. <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">item</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">current</span><span class="p">)</span>
  70. </pre></div>
  71. </div>
  72. </div>
  73. </div>
  74. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  75. <div class="sphinxsidebarwrapper">
  76. <h1 class="logo"><a href="../../index.html">Image Features Extraction</a></h1>
  77. <h3>Navigation</h3>
  78. <ul>
  79. <li class="toctree-l1"><a class="reference internal" href="../../tutorial.html">Tutorial</a></li>
  80. <li class="toctree-l1"><a class="reference internal" href="../../code.html">Classes/Modules</a></li>
  81. </ul>
  82. <div class="relations">
  83. <h3>Related Topics</h3>
  84. <ul>
  85. <li><a href="../../index.html">Documentation overview</a><ul>
  86. <li><a href="../index.html">Module code</a><ul>
  87. </ul></li>
  88. </ul></li>
  89. </ul>
  90. </div>
  91. <div id="searchbox" style="display: none" role="search">
  92. <h3>Quick search</h3>
  93. <form class="search" action="../../search.html" method="get">
  94. <div><input type="text" name="q" /></div>
  95. <div><input type="submit" value="Go" /></div>
  96. <input type="hidden" name="check_keywords" value="yes" />
  97. <input type="hidden" name="area" value="default" />
  98. </form>
  99. </div>
  100. <script type="text/javascript">$('#searchbox').show(0);</script>
  101. </div>
  102. </div>
  103. <div class="clearer"></div>
  104. </div>
  105. <div class="footer">
  106. &copy;2017, Remigio Picone.
  107. |
  108. Powered by <a href="http://sphinx-doc.org/">Sphinx 1.6.3</a>
  109. &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.10</a>
  110. </div>
  111. </body>
  112. </html>