This file is indexed.

/usr/share/doc/psi4/html/optionshandling.html is in psi4-data 1:0.3-5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>LibOptions: globals, locals, has_changed and all that &mdash; Psi4 [] Docs</title>
    
    <link rel="stylesheet" href="_static/psi4.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="./" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <script type="text/javascript" src="_static/jquery.cookie.js"></script>
    <script type="text/javascript" src="_static/toggle_sections.js"></script>
    <script type="text/javascript" src="_static/toggle_sidebar.js"></script>
    <script type="text/javascript" src="_static/toggle_codeprompt.js"></script>
    <link rel="shortcut icon" href="_static/favicon-psi4.ico"/>
    <link rel="top" title="Psi4 [] Docs" href="index.html" />
    <link rel="up" title="Programming: Using the Core Libraries" href="programming.html" />
    <link rel="next" title="Adding Methods to Driver" href="proc_py.html" />
    <link rel="prev" title="Programming: Using the Core Libraries" href="programming.html" /> 
  </head>
  <body role="document">
    <div class="relbar-top">
        
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> &nbsp; &nbsp;</li>
        <li class="right" >
          <a href="contents.html" title="Table Of Contents"
             accesskey="C">toc</a> &nbsp; &nbsp;</li>
        <li class="right" >
          <a href="proc_py.html" title="Adding Methods to Driver"
             accesskey="N">next</a> &nbsp; &nbsp;</li>
        <li class="right" >
          <a href="programming.html" title="Programming: Using the Core Libraries"
             accesskey="P">previous</a> &nbsp; &nbsp;</li>
    <li><a href="index.html">Psi4 []</a> &raquo; </li>

          <li class="nav-item nav-item-1"><a href="programming.html" accesskey="U">Programming: Using the Core Libraries</a> &raquo;</li> 
      </ul>
    </div>
    </div>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <a class="reference internal image-reference" href="_images/psi4banner.png"><img alt="Psi4 Project Logo" src="_images/psi4banner.png" style="width: 100%;" /></a>
<div class="section" id="liboptions-globals-locals-has-changed-and-all-that">
<span id="sec-handlingoptions-py"></span><h1>LibOptions: globals, locals, has_changed and all that<a class="headerlink" href="#liboptions-globals-locals-has-changed-and-all-that" title="Permalink to this headline"></a></h1>
<p>To simplify parsing of options and handling of defaults, the Options class
was created. It functions in the following way:</p>
<ul class="simple">
<li>Each module (or plugin) declares which options it will look for in the
input: their name, type (string, int, double, array, etc.), and any
default value they take.</li>
<li>The input is parsed for these options, and defaults are assigned for
those keywords not specified by the user.</li>
<li>The c-side module or plugin can then query the Options object for the
values associated with each keyword.</li>
<li>The options will also be accessible py-side to the procedures that drive
the modules. Array-type options are not available in python.</li>
</ul>
<div class="section" id="declaring-options">
<h2>Declaring Options<a class="headerlink" href="#declaring-options" title="Permalink to this headline"></a></h2>
<p>Each module needs to make itself known to the Options object, via a
read_options function. For plugins, this routine is provided by the user
in the plugin code. For native <span class="sc">Psi4</span> modules, the entries need to
be appended to the read_options code in <a class="reference external" href="https://github.com/psi4/psi4public/blob/master/src/bin/psi4/read_options.cc">psi4/src/bin/psi4/read_options.cc</a>.
An example of such a routine is</p>
<div class="highlight-python"><div class="highlight"><pre>if (name == &quot;MYMODULE&quot;|| options.read_globals()) {
    /*- The amount of information printed
    to the output file -*/
    options.add_int(&quot;PRINT&quot;, 1);
    /*- Do save information to |mymodule__data_file| at the end of the computation? -*/
    options.add_bool(&quot;SAVE_INFO&quot;, true);
    /*- An array containing the number of doubly occupied orbitals per irrep
    (in :ref:`Cotton order &lt;table:irrepOrdering&gt;`) -*/
    options.add(&quot;DOCC&quot;, new ArrayType());
    /*- The factor by which the harmonic vibrational frequencies are multiplied to
    obtain an approximation to the fundamental vibrational frequencies -*/
    options.add_double(&quot;FREQUENCY_SCALE_FACTOR&quot;, 1.0);
    /*- The filename to which data is dumped. !expert -*/
    options.add_str(&quot;DATA_FILE&quot;, &quot;data.dat&quot;);
    /*- The algorithm to use for the $\left&lt;VV||VV\right&gt;$ terms -*/
    options.add_str(&quot;AO_BASIS&quot;, &quot;NONE&quot;, &quot;NONE DISK DIRECT&quot;);
}
</pre></div>
</div>
<p>In the above example, the following options are declared (in order):</p>
<ul class="simple">
<li>An integer called <code class="docutils literal"><span class="pre">PRINT</span></code> with a default value of 1.</li>
<li>A boolean called <code class="docutils literal"><span class="pre">SAVE_INFO</span></code> with a default of true.</li>
<li>An array called <code class="docutils literal"><span class="pre">DOCC</span></code>, no default is possible for this type.</li>
<li>A double called <code class="docutils literal"><span class="pre">FREQUENCY_SCALE_FACTOR</span></code> with a default of 1.0.</li>
<li>A string called <code class="docutils literal"><span class="pre">DATA_FILE</span></code>, with a default of &#8220;data.dat&#8221; and any possible value.</li>
<li>A string called <code class="docutils literal"><span class="pre">AO_BASIS</span></code> with a default of &#8220;NONE&#8221;, and possible values of &#8220;NONE&#8221;, &#8220;DISK&#8221;, or &#8220;DIRECT&#8221;.</li>
</ul>
<p>The purpose of the &#8220;if&#8221; statement in the above read_options function is
the following. Suppose in an input file the user sets an option through
the construct <code class="docutils literal"><span class="pre">set</span> <span class="pre">mymodule</span> <span class="pre">print</span> <span class="pre">1</span></code> or through a <code class="docutils literal"><span class="pre">set</span> <span class="pre">mymodule</span> <span class="pre">{...}</span></code>
block. The first thing to happen is a call to read_options with name set
to &#8220;MYMODULE&#8221;. (Note that all user input is converted to upper case.) This
call to read_options should tell the Options object only about those
options expected by the module called &#8220;mymodule&#8221;; this prevents overlap of
options between different modules.</p>
<p>Notice also that there&#8217;s a special comment immediately before the
declaration of each keyword. You must provide these comments for any
options you add as they will be automatically inserted into the user
manual Providing a clear description will also help you to remember what
the keywords do and how they&#8217;re used. The comments must live between the
special comment delimiters. For options that most users shouldn&#8217;t need,
add an expert flag to the comment. This will place these options in a
separate section of the user manual.</p>
<div class="highlight-python"><div class="highlight"><pre>/*- comment -*/
options.add_ ...
/*- comment !expert -*/
options.add_ ...
</pre></div>
</div>
<p>As is apparent from the examples above, comments can span multiple lines
(see <code class="docutils literal"><span class="pre">PRINT</span></code>), can refer to other options (through hyperlinks; see
<code class="docutils literal"><span class="pre">SAVE_INFO</span></code>), can refer to sections of the manual (through hyperlinks;
see <code class="docutils literal"><span class="pre">DOCC</span></code>), and can contain LaTeX notation (see <code class="docutils literal"><span class="pre">AO_BASIS</span></code>). (To get
the LaTeX subscript command, use &#8220;&#64;&#64;&#8221; instead of &#8220;_&#8221;.)</p>
<p>See <a class="reference external" href="https://github.com/psi4/psi4public/wiki/BestPractices#how-to-name-keywords-in-srcbinpsi4read_optionscc">Best Practices</a>
for guidelines on naming options.</p>
</div>
<div class="section" id="what-is-has-changed">
<h2>What is <em>has_changed</em> ?<a class="headerlink" href="#what-is-has-changed" title="Permalink to this headline"></a></h2>
<p>There are times when we need to know whether an option was provided by the
user or if the defaults are being used. For this reason, the Options
object stores a boolean <em>has_changed</em> value, in addition to the option
value itself.  A clarification of definition:</p>
<ul class="simple">
<li>[a] has_changed DOESN&#8217;T answer &#8220;Has option been changed by the user?&#8221;</li>
<li>[b] has_changed DOESN&#8217;T answer &#8220;Is option now different from the default?&#8221;</li>
<li>[c] has_changed DOES answer &#8220;Has option value been touched at all, by user or code?&#8221;</li>
</ul>
<p>The above items notwithstanding, psi4 code should be written so that
<em>has_changed</em> DOES effectively mean, &#8220;Has option been changed by the
user?&#8221;. The way to do this is to isolate and nullify any changes to
options made by the code, the difference between [a] and [c]. C-side,
there is no concern since options are read but essentially never
written-to within the modules.</p>
<p>Py-side is another matter since the driver&#8217;s role is to take terse
instructions from the user and translate those into instructions to the
C++ modules, usually through manipulation of options.</p>
<p>In order to preserve effective definition [a], the strategy for each
python driver function is to query for the value of any option the
function may want to change and for the current has_changed status
(presumably reflecting whether the user has changed the value, as long as
no preceeding code has corrupted that definition). The python function
then makes its changes to the option and runs any c-side modules with
those changes. Finally, just before the function returns, the options are
reset to the user&#8217;s value and has_changed status (which should now again
reflect only whether the user has changed the value).</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last"><a class="reference internal" href="autodoc_glossary_options_c.html#term-puream-globals"><span class="xref std std-term">PUREAM</span></a> is an exception in that its value and
<code class="docutils literal"><span class="pre">has_changed()</span></code> value only reflect what the user has explicitly set.
This keyword should not be queried to find out the current
<a class="reference internal" href="autodoc_glossary_options_c.html#term-puream-globals"><span class="xref std std-term">PUREAM</span></a> state for the active basis; use instead,
<code class="docutils literal"><span class="pre">psi4.MintsHelper().basisset().has_puream()</span></code>.</p>
</div>
</div>
<div class="section" id="reading-options-in-module">
<h2>Reading Options in Module<a class="headerlink" href="#reading-options-in-module" title="Permalink to this headline"></a></h2>
</div>
<div class="section" id="handling-options-in-driver">
<h2>Handling Options in Driver<a class="headerlink" href="#handling-options-in-driver" title="Permalink to this headline"></a></h2>
<p>This section is about the scopes of options and how best to handle them in
the python driver. There are four groups of commands available.
Options from the c-side Options object are accessible in the Python driver through four sets of commands.</p>
<ul class="simple">
<li>get<ul>
<li><a class="reference internal" href="autodoc_psimod.html#psi4.get_global_option" title="psi4.get_global_option"><code class="xref py py-func docutils literal"><span class="pre">get_global_option()</span></code></a></li>
<li><a class="reference internal" href="autodoc_psimod.html#psi4.get_local_option" title="psi4.get_local_option"><code class="xref py py-func docutils literal"><span class="pre">get_local_option()</span></code></a></li>
<li><a class="reference internal" href="autodoc_psimod.html#psi4.get_option" title="psi4.get_option"><code class="xref py py-func docutils literal"><span class="pre">get_option()</span></code></a></li>
</ul>
</li>
<li>set<ul>
<li><a class="reference internal" href="autodoc_psimod.html#psi4.set_global_option" title="psi4.set_global_option"><code class="xref py py-func docutils literal"><span class="pre">set_global_option()</span></code></a></li>
<li><a class="reference internal" href="autodoc_psimod.html#psi4.set_local_option" title="psi4.set_local_option"><code class="xref py py-func docutils literal"><span class="pre">set_local_option()</span></code></a></li>
</ul>
</li>
<li>has_changed<ul>
<li><a class="reference internal" href="autodoc_psimod.html#psi4.has_global_option_changed" title="psi4.has_global_option_changed"><code class="xref py py-func docutils literal"><span class="pre">has_global_option_changed()</span></code></a></li>
<li><a class="reference internal" href="autodoc_psimod.html#psi4.has_local_option_changed" title="psi4.has_local_option_changed"><code class="xref py py-func docutils literal"><span class="pre">has_local_option_changed()</span></code></a></li>
<li><a class="reference internal" href="autodoc_psimod.html#psi4.has_option_changed" title="psi4.has_option_changed"><code class="xref py py-func docutils literal"><span class="pre">has_option_changed()</span></code></a></li>
</ul>
</li>
<li>revoke_changed<ul>
<li><a class="reference internal" href="autodoc_psimod.html#psi4.revoke_global_option_changed" title="psi4.revoke_global_option_changed"><code class="xref py py-func docutils literal"><span class="pre">revoke_global_option_changed()</span></code></a></li>
<li><a class="reference internal" href="autodoc_psimod.html#psi4.revoke_local_option_changed" title="psi4.revoke_local_option_changed"><code class="xref py py-func docutils literal"><span class="pre">revoke_local_option_changed()</span></code></a></li>
</ul>
</li>
</ul>
<p>There&#8217;s a pattern here. Setting something, either a value (set) or a
negative changed status (revoke_changed), can only be done for a specific
scope, either global or local to the specified module. Querying, either a
value (get) or a changed status (has_changed), can be done in the global
scope, in a specified local scope, or in the context of &#8220;What will the
specified module use?&#8221;.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">&#8220;Global&#8221; in the sense of the discussion has <em>nothing</em>
to do with the globals section at the top of read_options.cc .  That
section is just a convenient place for options and associated values
that are used by most, if not all, modules.</p>
</div>
<p>There are two primary purposes for interacting with options in the python driver.</p>
<ul>
<li><p class="first"><strong>Preserving User Options</strong> (Enforcing definition [a] of has_changed)</p>
<p>The first, less-interesting, use of retrieving user option values has
been to preserve them so that they may be restored at the end after the
procedure itself has clobbered them. By decoupling global_option and
local_option commands, this can now be performed neatly by saving at the
beginning the global and local values and the global and local
has_changed values, then restoring them at the end.  Below is an example
of this procedure; don&#8217;t actually do this.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">g_user_scftype</span> <span class="o">=</span> <span class="n">psi4</span><span class="o">.</span><span class="n">get_global_option</span><span class="p">(</span><span class="s">&#39;SCF_TYPE&#39;</span><span class="p">)</span>
<span class="n">l_user_scftype_scf</span> <span class="o">=</span> <span class="n">psi4</span><span class="o">.</span><span class="n">get_local_option</span><span class="p">(</span><span class="s">&#39;SCF&#39;</span><span class="p">,</span> <span class="s">&#39;SCF_TYPE&#39;</span><span class="p">)</span>
<span class="n">bg_user_scftype</span> <span class="o">=</span> <span class="n">psi4</span><span class="o">.</span><span class="n">has_global_option_changed</span><span class="p">(</span><span class="s">&#39;SCF_TYPE&#39;</span><span class="p">)</span>
<span class="n">bl_user_scftype_scf</span> <span class="o">=</span> <span class="n">psi4</span><span class="o">.</span><span class="n">has_local_option_changed</span><span class="p">(</span><span class="s">&#39;SCF&#39;</span><span class="p">,</span> <span class="s">&#39;SCF_TYPE&#39;</span><span class="p">)</span>

<span class="n">g_user_wfn</span> <span class="o">=</span> <span class="n">psi4</span><span class="o">.</span><span class="n">get_global_option</span><span class="p">(</span><span class="s">&#39;WFN&#39;</span><span class="p">)</span>
<span class="n">l_user_wfn</span> <span class="o">=</span> <span class="n">psi4</span><span class="o">.</span><span class="n">get_local_option</span><span class="p">(</span><span class="s">&#39;MP2&#39;</span><span class="p">,</span> <span class="s">&#39;WFN&#39;</span><span class="p">)</span>
<span class="n">bg_user_wfn</span> <span class="o">=</span> <span class="n">psi4</span><span class="o">.</span><span class="n">has_global_option_changed</span><span class="p">(</span><span class="s">&#39;WFN&#39;</span><span class="p">)</span>
<span class="n">bl_user_wfn</span> <span class="o">=</span> <span class="n">psi4</span><span class="o">.</span><span class="n">has_local_option_changed</span><span class="p">(</span><span class="s">&#39;MP2&#39;</span><span class="p">,</span> <span class="s">&#39;WFN&#39;</span><span class="p">)</span>

<span class="c"># body of function</span>
<span class="c"># scf_type and wfn are freely changed, LOCALLY</span>
<span class="c"># psi4.scf() and psi4.mp2() are run</span>

<span class="n">psi4</span><span class="o">.</span><span class="n">set_global_option</span><span class="p">(</span><span class="s">&#39;SCF_TYPE&#39;</span><span class="p">,</span> <span class="n">g_user_scftype</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">bg_user_scftype</span><span class="p">:</span>
    <span class="n">psi4</span><span class="o">.</span><span class="n">revoke_global_option_changed</span><span class="p">(</span><span class="s">&#39;SCF_TYPE&#39;</span><span class="p">)</span>
<span class="n">psi4</span><span class="o">.</span><span class="n">set_local_option</span><span class="p">(</span><span class="s">&#39;SCF&#39;</span><span class="p">,</span> <span class="s">&#39;SCF_TYPE&#39;</span><span class="p">,</span> <span class="n">l_user_scftype_scf</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">bl_user_scftype_scf</span><span class="p">:</span>
    <span class="n">psi4</span><span class="o">.</span><span class="n">revoke_local_option_changed</span><span class="p">(</span><span class="s">&#39;SCF&#39;</span><span class="p">,</span> <span class="s">&#39;SCF_TYPE&#39;</span><span class="p">)</span>

<span class="n">psi4</span><span class="o">.</span><span class="n">set_global_option</span><span class="p">(</span><span class="s">&#39;WFN&#39;</span><span class="p">,</span> <span class="n">g_user_wfn</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">bg_user_wfn</span><span class="p">:</span>
    <span class="n">psi4</span><span class="o">.</span><span class="n">revoke_global_option_changed</span><span class="p">(</span><span class="s">&#39;WFN&#39;</span><span class="p">)</span>
<span class="n">psi4</span><span class="o">.</span><span class="n">set_local_option</span><span class="p">(</span><span class="s">&#39;MP2&#39;</span><span class="p">,</span> <span class="s">&#39;WFN&#39;</span><span class="p">,</span> <span class="n">l_user_wfn_scf</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">bl_user_wfn_scf</span><span class="p">:</span>
    <span class="n">psi4</span><span class="o">.</span><span class="n">revoke_local_option_changed</span><span class="p">(</span><span class="s">&#39;MP2&#39;</span><span class="p">,</span> <span class="s">&#39;WFN&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>Instead of cluttering the driver with the above boilerplate, use an
<code class="xref py py-class docutils literal"><span class="pre">OptionsState</span></code> object that stores values and
has_changed values for each keyword and module pair given to it as
arguments. At the end of the python function, these stored user settings
can be restored.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">optstash</span> <span class="o">=</span> <span class="n">OptionsState</span><span class="p">(</span>
    <span class="p">[</span><span class="s">&#39;SCF&#39;</span><span class="p">,</span> <span class="s">&#39;SCF_TYPE&#39;</span><span class="p">],</span>
    <span class="p">[</span><span class="s">&#39;MP2&#39;</span><span class="p">,</span> <span class="s">&#39;WFN&#39;</span><span class="p">],</span>
    <span class="p">[</span><span class="s">&#39;DF_BASIS_SCF&#39;</span><span class="p">])</span>

<span class="c"># body of function</span>
<span class="c"># scf_type and wfn are freely changed, LOCALLY</span>
<span class="c"># puream and df_basis_scf are freely changed, GLOBALLY</span>
<span class="c"># psi4.scf() and psi4.mp2() are run</span>

<span class="n">optstash</span><span class="o">.</span><span class="n">restore</span><span class="p">()</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Some options (BASIS, BASIS-like, and PUREAM) should always
be used globally (no module argument) with the OptionsState objects.
Similarly, within the body of the function, they should always be
queried and set globally. Same for FREEZE_CORE.</p>
</div>
</li>
<li><p class="first"><strong>Setting-Up Calculations</strong></p>
<p>The other types of options calls in python driver functions are (a)
those to query what option value an upcoming c++ module is going to use
(determined by user and defaults) and (b) those to set options to govern
the course of a procedure. Finding out the intended option value for a
molecule should employ the <a class="reference internal" href="autodoc_psimod.html#psi4.get_option" title="psi4.get_option"><code class="xref py py-func docutils literal"><span class="pre">get_option()</span></code></a> command
(and <a class="reference internal" href="autodoc_psimod.html#psi4.has_option_changed" title="psi4.has_option_changed"><code class="xref py py-func docutils literal"><span class="pre">has_option_changed()</span></code></a> for has_changed), which
(newly) requires a module for scope. <em>(Previously, this command used the
&#8220;active module&#8221;, which isn&#8217;t well-defined in the context of the python
driver, and consequently, the command gave variable results, depending
on whether a get_local/set_local command had been previously executed to
define the active module.)</em></p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">if</span> <span class="p">(</span><span class="n">psi4</span><span class="o">.</span><span class="n">get_option</span><span class="p">(</span><span class="s">&#39;SCF&#39;</span><span class="p">,</span> <span class="s">&#39;REFERENCE&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="s">&#39;RHF&#39;</span><span class="p">):</span>
    <span class="n">psi4</span><span class="o">.</span><span class="n">set_local_option</span><span class="p">(</span><span class="s">&#39;SCF&#39;</span><span class="p">,</span> <span class="s">&#39;REFERENCE&#39;</span><span class="p">,</span> <span class="s">&#39;RKS&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>Setting of options in python should use the
<a class="reference internal" href="autodoc_psimod.html#psi4.set_local_option" title="psi4.set_local_option"><code class="xref py py-func docutils literal"><span class="pre">set_local_option()</span></code></a> command. Using the local, rather
than global, scope will ensure that the newly set option will be used by
the module. Otherwise, if the python procedure set in the global scope
and the user had happened to set that option in local scope, the local
user option will take precedence against the programmer&#8217;s intent.
<em>(Anyone who has heard advice to &#8220;query local, set global&#8221; should forget
that and follow the new scheme outlined here.)</em></p>
</li>
</ul>
<style type="text/css"><!--
 .green {color: red;}
 .sc {font-variant: small-caps;}
 --></style></div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">LibOptions: globals, locals, has_changed and all that</a><ul>
<li><a class="reference internal" href="#declaring-options">Declaring Options</a></li>
<li><a class="reference internal" href="#what-is-has-changed">What is <em>has_changed</em> ?</a></li>
<li><a class="reference internal" href="#reading-options-in-module">Reading Options in Module</a></li>
<li><a class="reference internal" href="#handling-options-in-driver">Handling Options in Driver</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="programming.html"
                        title="previous chapter">Programming: Using the Core Libraries</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="proc_py.html"
                        title="next chapter">Adding Methods to Driver</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="_sources/optionshandling.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="relbar-bottom">
        
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> &nbsp; &nbsp;</li>
        <li class="right" >
          <a href="contents.html" title="Table Of Contents"
             >toc</a> &nbsp; &nbsp;</li>
        <li class="right" >
          <a href="proc_py.html" title="Adding Methods to Driver"
             >next</a> &nbsp; &nbsp;</li>
        <li class="right" >
          <a href="programming.html" title="Programming: Using the Core Libraries"
             >previous</a> &nbsp; &nbsp;</li>
    <li><a href="index.html">Psi4 []</a> &raquo; </li>

          <li class="nav-item nav-item-1"><a href="programming.html" >Programming: Using the Core Libraries</a> &raquo;</li> 
      </ul>
    </div>
    </div>

    <div class="footer" role="contentinfo">
        &copy; Copyright 2015, The Psi4 Project.
      Last updated on Tuesday, 12 January 2016 03:10PM.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.3.3.
    </div>
    <!-- cloud_sptheme 1.3 -->
  </body>
</html>