PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/docs/1.1.8/generated/cf.OF_FRACTION.html

https://bitbucket.org/cfpython/cfpython.bitbucket.org
HTML | 221 lines | 177 code | 14 blank | 30 comment | 0 complexity | 9c3d365167f0c303d80bf10a30b3fc5d MD5 | raw file
  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>cf.OF_FRACTION &mdash; Documentation</title>
  7. <link rel="stylesheet" href="../_static/classic.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.1.8',
  13. COLLAPSE_INDEX: false,
  14. FILE_SUFFIX: '.html',
  15. HAS_SOURCE: true
  16. };
  17. </script>
  18. <script type="text/javascript" src="../_static/jquery.js"></script>
  19. <script type="text/javascript" src="../_static/underscore.js"></script>
  20. <script type="text/javascript" src="../_static/doctools.js"></script>
  21. <script type="text/javascript" src="../_static/copybutton.js"></script>
  22. <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
  23. <link rel="top" title="Documentation" href="../index.html" />
  24. <link rel="up" title="Functions of the cf module" href="../function.html" />
  25. <link rel="next" title="cf.REGRID_LOGGING" href="cf.REGRID_LOGGING.html" />
  26. <link rel="prev" title="cf.MINNCFM" href="cf.MINNCFM.html" />
  27. </head>
  28. <body role="document">
  29. <div class="related" role="navigation" aria-label="related navigation">
  30. <h3>Navigation</h3>
  31. <ul>
  32. <li class="right" style="margin-right: 10px">
  33. <a href="../genindex.html" title="General Index"
  34. accesskey="I">index</a></li>
  35. <li class="right" >
  36. <a href="cf.REGRID_LOGGING.html" title="cf.REGRID_LOGGING"
  37. accesskey="N">next</a> |</li>
  38. <li class="right" >
  39. <a href="cf.MINNCFM.html" title="cf.MINNCFM"
  40. accesskey="P">previous</a> |</li>
  41. <li><a target="_blank" href="http://cfpython.bitbucket.org">cf-python 1.1.8</a> &raquo;</li>
  42. <!--
  43. <li><a target="_blank" href="http://cfpython.bitbucket.org">cf-python</a> &raquo;</li>
  44. <li><select onchange="location = this.options[this.selectedIndex].value;">
  45. <option value="../../1.0/index.html">1.0
  46. <option value="../../0.9.9/index.html">0.9.9
  47. <option value="../../0.9.8.3/index.html">0.9.8.3
  48. <option value="../../archive.html">Archive
  49. </select>
  50. </li>
  51. -->
  52. <li class="nav-item nav-item-0"><a href="../index.html">Documentation</a> &raquo;</li>
  53. <li class="nav-item nav-item-1"><a href="../reference.html" >Reference manual</a> &raquo;</li>
  54. <li class="nav-item nav-item-2"><a href="../function.html" accesskey="U">Functions of the <code class="docutils literal"><span class="pre">cf</span></code> module</a> &raquo;</li>
  55. </ul>
  56. </div>
  57. <div class="document">
  58. <div class="documentwrapper">
  59. <div class="bodywrapper">
  60. <div class="body" role="main">
  61. <div class="section" id="cf-of-fraction">
  62. <h1>cf.OF_FRACTION<a class="headerlink" href="#cf-of-fraction" title="Permalink to this headline"></a></h1>
  63. <dl class="function">
  64. <dt id="cf.OF_FRACTION">
  65. <code class="descclassname">cf.</code><code class="descname">OF_FRACTION</code><span class="sig-paren">(</span><em>*arg</em><span class="sig-paren">)</span><a class="reference external" href="https://bitbucket.org/cfpython/cf-python/src/v1.1.8/cf/functions.py#functions.py-361"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#cf.OF_FRACTION" title="Permalink to this definition"></a></dt>
  66. <dd><p>The amount of concurrently open files above which files containing
  67. data arrays may be automatically closed.</p>
  68. <p>The amount is expressed as a fraction of the maximum possible number
  69. of concurrently open files.</p>
  70. <p>Note that closed files will be automatically reopened if subsequently
  71. needed by a variable to access its data array.</p>
  72. <table class="docutils field-list" frame="void" rules="none">
  73. <col class="field-name" />
  74. <col class="field-body" />
  75. <tbody valign="top">
  76. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><dl class="first docutils">
  77. <dt>arg <span class="classifier-delimiter">:</span> <span class="classifier">float, optional</span></dt>
  78. <dd><p class="first last">The new fraction (between 0.0 and 1.0). The default is to not
  79. change the current behaviour.</p>
  80. </dd>
  81. </dl>
  82. </td>
  83. </tr>
  84. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><dl class="first last docutils">
  85. <dt>out <span class="classifier-delimiter">:</span> <span class="classifier">float</span></dt>
  86. <dd><p class="first last">The value prior to the change, or the current value if no new
  87. value was specified.</p>
  88. </dd>
  89. </dl>
  90. </td>
  91. </tr>
  92. </tbody>
  93. </table>
  94. <div class="admonition seealso">
  95. <p class="first admonition-title">See also</p>
  96. <p class="last"><a class="reference internal" href="cf.close_files.html#cf.close_files" title="cf.close_files"><code class="xref py py-obj docutils literal"><span class="pre">cf.close_files</span></code></a>, <a class="reference internal" href="cf.close_one_file.html#cf.close_one_file" title="cf.close_one_file"><code class="xref py py-obj docutils literal"><span class="pre">cf.close_one_file</span></code></a>, <a class="reference internal" href="cf.open_files.html#cf.open_files" title="cf.open_files"><code class="xref py py-obj docutils literal"><span class="pre">cf.open_files</span></code></a>,
  97. <a class="reference internal" href="cf.open_files_threshold_exceeded.html#cf.open_files_threshold_exceeded" title="cf.open_files_threshold_exceeded"><code class="xref py py-obj docutils literal"><span class="pre">cf.open_files_threshold_exceeded</span></code></a></p>
  98. </div>
  99. <table class="docutils field-list" frame="void" rules="none">
  100. <col class="field-name" />
  101. <col class="field-body" />
  102. <tbody valign="top">
  103. <tr class="field-odd field"><th class="field-name">Examples:</th><td class="field-body"></td>
  104. </tr>
  105. </tbody>
  106. </table>
  107. <div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">cf</span><span class="o">.</span><span class="n">OF_FRACTION</span><span class="p">()</span>
  108. <span class="go">0.5</span>
  109. <span class="gp">&gt;&gt;&gt; </span><span class="n">old</span> <span class="o">=</span> <span class="n">cf</span><span class="o">.</span><span class="n">OF_FRACTION</span><span class="p">(</span><span class="mf">0.33</span><span class="p">)</span>
  110. <span class="gp">&gt;&gt;&gt; </span><span class="n">cf</span><span class="o">.</span><span class="n">OF_FRACTION</span><span class="p">(</span><span class="n">old</span><span class="p">)</span>
  111. <span class="go">0.33</span>
  112. <span class="gp">&gt;&gt;&gt; </span><span class="n">cf</span><span class="o">.</span><span class="n">OF_FRACTION</span><span class="p">()</span>
  113. <span class="go">0.5</span>
  114. </pre></div>
  115. </div>
  116. <p>The fraction may be translated to an actual number of files as
  117. follows:</p>
  118. <div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">old</span> <span class="o">=</span> <span class="n">cf</span><span class="o">.</span><span class="n">OF_FRACTION</span><span class="p">(</span><span class="mf">0.75</span><span class="p">)</span>
  119. <span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">resource</span>
  120. <span class="gp">&gt;&gt;&gt; </span><span class="n">max_open_files</span> <span class="o">=</span> <span class="n">resource</span><span class="o">.</span><span class="n">getrlimit</span><span class="p">(</span><span class="n">resource</span><span class="o">.</span><span class="n">RLIMIT_NOFILE</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
  121. <span class="gp">&gt;&gt;&gt; </span><span class="n">threshold</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">max_open_files</span> <span class="o">*</span> <span class="n">cf</span><span class="o">.</span><span class="n">OF_FRACTION</span><span class="p">())</span>
  122. <span class="gp">&gt;&gt;&gt; </span><span class="n">max_open_files</span><span class="p">,</span> <span class="n">threshold</span>
  123. <span class="go">(1024, 768)</span>
  124. </pre></div>
  125. </div>
  126. </dd></dl>
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  132. <div class="sphinxsidebarwrapper">
  133. <h4>Previous topic</h4>
  134. <p class="topless"><a href="cf.MINNCFM.html"
  135. title="previous chapter">cf.MINNCFM</a></p>
  136. <h4>Next topic</h4>
  137. <p class="topless"><a href="cf.REGRID_LOGGING.html"
  138. title="next chapter">cf.REGRID_LOGGING</a></p>
  139. <div role="note" aria-label="source link">
  140. <h3>This Page</h3>
  141. <ul class="this-page-menu">
  142. <li><a href="../_sources/generated/cf.OF_FRACTION.txt"
  143. rel="nofollow">Show Source</a></li>
  144. </ul>
  145. </div>
  146. <div id="searchbox" style="display: none" role="search">
  147. <h3>Quick search</h3>
  148. <form class="search" action="../search.html" method="get">
  149. <input type="text" name="q" />
  150. <input type="submit" value="Go" />
  151. <input type="hidden" name="check_keywords" value="yes" />
  152. <input type="hidden" name="area" value="default" />
  153. </form>
  154. <p class="searchtip" style="font-size: 90%">
  155. Enter search terms or a module, class or function name.
  156. </p>
  157. </div>
  158. <script type="text/javascript">$('#searchbox').show(0);</script>
  159. </div>
  160. </div>
  161. <div class="clearer"></div>
  162. </div>
  163. <div class="related" role="navigation" aria-label="related navigation">
  164. <h3>Navigation</h3>
  165. <ul>
  166. <li class="right" style="margin-right: 10px">
  167. <a href="../genindex.html" title="General Index"
  168. >index</a></li>
  169. <li class="right" >
  170. <a href="cf.REGRID_LOGGING.html" title="cf.REGRID_LOGGING"
  171. >next</a> |</li>
  172. <li class="right" >
  173. <a href="cf.MINNCFM.html" title="cf.MINNCFM"
  174. >previous</a> |</li>
  175. <li><a target="_blank" href="http://cfpython.bitbucket.org">cf-python 1.1.8</a> &raquo;</li>
  176. <!--
  177. <li><a target="_blank" href="http://cfpython.bitbucket.org">cf-python</a> &raquo;</li>
  178. <li><select onchange="location = this.options[this.selectedIndex].value;">
  179. <option value="../../1.0/index.html">1.0
  180. <option value="../../0.9.9/index.html">0.9.9
  181. <option value="../../0.9.8.3/index.html">0.9.8.3
  182. <option value="../../archive.html">Archive
  183. </select>
  184. </li>
  185. -->
  186. <li class="nav-item nav-item-0"><a href="../index.html">Documentation</a> &raquo;</li>
  187. <li class="nav-item nav-item-1"><a href="../reference.html" >Reference manual</a> &raquo;</li>
  188. <li class="nav-item nav-item-2"><a href="../function.html" >Functions of the <code class="docutils literal"><span class="pre">cf</span></code> module</a> &raquo;</li>
  189. </ul>
  190. </div>
  191. <div class="footer" role="contentinfo">
  192. &copy; Copyright 2016, David Hassell.
  193. Last updated on May 18, 2016.
  194. Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.3.5.
  195. </div>
  196. </body>
  197. </html>