<html><body>
<p>2 new commits in yt:</p>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/b06aadf73a03/">https://bitbucket.org/yt_analysis/yt/commits/b06aadf73a03/</a> Changeset:   b06aadf73a03 Branch:      yt User:        ngoldbaum Date:        2016-03-25 03:48:42+00:00 Summary:     Documenting the enable_plugins function. Closes #1030.</p>
<p>Also de-emphasizing discussion of yt.mods, since this obviates most of the need to use yt.mods just to get at the plugins file. Affected #:  3 files</p>
<p>diff -r a776e67368c5629296b1e365dfca0b68b41ef1d5 -r b06aadf73a03650f3f1ae6395fa4c5522d4675b7 doc/source/reference/api/api.rst --- a/doc/source/reference/api/api.rst +++ b/doc/source/reference/api/api.rst @@ -791,6 +791,7 @@</p>
<pre>~yt.data_objects.static_output.Dataset.box
~yt.funcs.deprecate
~yt.funcs.ensure_list</pre>
<p>+   ~yt.funcs.enable_plugins</p>
<pre>~yt.funcs.get_pbar
~yt.funcs.humanize_time
~yt.funcs.insert_ipython</pre>
<p>diff -r a776e67368c5629296b1e365dfca0b68b41ef1d5 -r b06aadf73a03650f3f1ae6395fa4c5522d4675b7 doc/source/reference/configuration.rst --- a/doc/source/reference/configuration.rst +++ b/doc/source/reference/configuration.rst @@ -124,25 +124,22 @@</p>
<pre>objects, colormaps, and other code classes and objects to be used in future
yt sessions without modifying the source code directly.
</pre>
<p>+To force the plugin file to be parsed, call the function +:func:`~yt.funcs.enable_plugins` at the top of your script.</p>
<pre>.. note::
</pre>
<ul><li><p>The ``my_plugins.py`` is only parsed inside of ``yt.mods``, so in order</p></li>
<li><p>to use it, you must load yt with either: ``import yt.mods as yt``</p></li>
<li><p>or ``from yt.mods import *``.  You can tell that your</p></li>
<li><p>plugins file is being parsed by watching for a logging message when you</p></li>
<li><p>import yt.  Note that both the ``yt load`` and ``iyt`` command line entry</p></li>
<li><p>points invoke ``from yt.mods import *``, so the ``my_plugins.py`` file</p></li>
<li><p>will be parsed if you enter yt that way.</p></li></ul>
<p>+   You can tell that your plugins file is being parsed by watching for a logging +   message when you import yt.  Note that both the ``yt load`` and ``iyt`` +   command line entry points parse the plugin file, so the ``my_plugins.py`` +   file will be parsed if you enter yt that way.</p>
<pre>Plugin File Format
^^^^^^^^^^^^^^^^^^
</pre>
<p>-yt will look for and recognize the file ``$HOME/.yt/my_plugins`` as a plugin +yt will look for and recognize the file ``$HOME/.yt/my_plugins.py`` as a plugin</p>
<pre>file, which should contain python code.  If accessing yt functions and classes
they will not require the ``yt.`` prefix, because of how they are loaded.</pre>
<p>-It is executed at the bottom of ``yt.mods``, and so -it is provided with the entire namespace available in the module ``yt.mods``.</p>
<pre>For example, if I created a plugin file containing:
</pre>
<p>@@ -152,7 +149,7 @@</p>
<pre>       return np.random.random(data["density"].shape)
   add_field("random", function=_myfunc, units='auto')
</pre>
<p>-then all of my data objects would have access to the field ``some_quantity``. +then all of my data objects would have access to the field ``random``.</p>
<pre>You can also define other convenience functions in your plugin file.  For
instance, you could define some variables or functions, and even import common</pre>
<p>@@ -176,13 +173,19 @@</p>
<pre>.. code-block:: python
</pre>
<ul><li><p>import yt.mods as yt</p></li></ul>
<p>+   import yt +   yt.enable_plugins()</p>
<pre>   my_run = yt.load_run("hotgasflow/DD0040/DD0040")
</pre>
<p>-And because we have imported from ``yt.mods`` we have access to the +And because we have used ``yt.enable_plugins`` we have access to the</p>
<pre>``load_run`` function defined in our plugin file.
</pre>
<p>+Note that using the plugins file implies that your script is no longer fully +reproducible. If you share your script with someone else and use some of the +functionality if your plugins file, you will also need to share your plugins +file for someone else to re-run your script properly. +</p>
<pre>Adding Custom Colormaps
^^^^^^^^^^^^^^^^^^^^^^^
</pre>
<p>diff -r a776e67368c5629296b1e365dfca0b68b41ef1d5 -r b06aadf73a03650f3f1ae6395fa4c5522d4675b7 yt/funcs.py --- a/yt/funcs.py +++ b/yt/funcs.py @@ -838,6 +838,17 @@</p>
<pre>    return _func

def enable_plugins():</pre>
<p>+    """Forces the plugins file to be parsed. + +    This plugin file is a means of creating custom fields, quantities, +    data objects, colormaps, and other code classes and objects to be used +    in yt scripts without modifying the yt source directly. + +    The file must be located at ``$HOME/.yt/my_plugins.py``. + +    Warning: when you use this function, your script will only be reproducible +    if you also provide the ``my_plugins.py`` file. +    """</p>
<pre>import yt
from yt.fields.my_plugin_fields import my_plugins_fields
from yt.config import ytcfg</pre>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/9fa87cf2500a/">https://bitbucket.org/yt_analysis/yt/commits/9fa87cf2500a/</a> Changeset:   9fa87cf2500a Branch:      yt User:        MatthewTurk Date:        2016-03-27 21:29:58+00:00 Summary:     Merged in ngoldbaum/yt (pull request #2081)</p>
<p>Documenting the enable_plugins function. Closes #1030. Affected #:  3 files</p>
<p>diff -r 299e448d91100b7009f3d95e7ee5409a07cbac9c -r 9fa87cf2500ac6560789c9a58f1f419bb12cbd7c doc/source/reference/api/api.rst --- a/doc/source/reference/api/api.rst +++ b/doc/source/reference/api/api.rst @@ -791,6 +791,7 @@</p>
<pre>~yt.data_objects.static_output.Dataset.box
~yt.funcs.deprecate
~yt.funcs.ensure_list</pre>
<p>+   ~yt.funcs.enable_plugins</p>
<pre>~yt.funcs.get_pbar
~yt.funcs.humanize_time
~yt.funcs.insert_ipython</pre>
<p>diff -r 299e448d91100b7009f3d95e7ee5409a07cbac9c -r 9fa87cf2500ac6560789c9a58f1f419bb12cbd7c doc/source/reference/configuration.rst --- a/doc/source/reference/configuration.rst +++ b/doc/source/reference/configuration.rst @@ -124,25 +124,22 @@</p>
<pre>objects, colormaps, and other code classes and objects to be used in future
yt sessions without modifying the source code directly.
</pre>
<p>+To force the plugin file to be parsed, call the function +:func:`~yt.funcs.enable_plugins` at the top of your script.</p>
<pre>.. note::
</pre>
<ul><li><p>The ``my_plugins.py`` is only parsed inside of ``yt.mods``, so in order</p></li>
<li><p>to use it, you must load yt with either: ``import yt.mods as yt``</p></li>
<li><p>or ``from yt.mods import *``.  You can tell that your</p></li>
<li><p>plugins file is being parsed by watching for a logging message when you</p></li>
<li><p>import yt.  Note that both the ``yt load`` and ``iyt`` command line entry</p></li>
<li><p>points invoke ``from yt.mods import *``, so the ``my_plugins.py`` file</p></li>
<li><p>will be parsed if you enter yt that way.</p></li></ul>
<p>+   You can tell that your plugins file is being parsed by watching for a logging +   message when you import yt.  Note that both the ``yt load`` and ``iyt`` +   command line entry points parse the plugin file, so the ``my_plugins.py`` +   file will be parsed if you enter yt that way.</p>
<pre>Plugin File Format
^^^^^^^^^^^^^^^^^^
</pre>
<p>-yt will look for and recognize the file ``$HOME/.yt/my_plugins`` as a plugin +yt will look for and recognize the file ``$HOME/.yt/my_plugins.py`` as a plugin</p>
<pre>file, which should contain python code.  If accessing yt functions and classes
they will not require the ``yt.`` prefix, because of how they are loaded.</pre>
<p>-It is executed at the bottom of ``yt.mods``, and so -it is provided with the entire namespace available in the module ``yt.mods``.</p>
<pre>For example, if I created a plugin file containing:
</pre>
<p>@@ -152,7 +149,7 @@</p>
<pre>       return np.random.random(data["density"].shape)
   add_field("random", function=_myfunc, units='auto')
</pre>
<p>-then all of my data objects would have access to the field ``some_quantity``. +then all of my data objects would have access to the field ``random``.</p>
<pre>You can also define other convenience functions in your plugin file.  For
instance, you could define some variables or functions, and even import common</pre>
<p>@@ -176,13 +173,19 @@</p>
<pre>.. code-block:: python
</pre>
<ul><li><p>import yt.mods as yt</p></li></ul>
<p>+   import yt +   yt.enable_plugins()</p>
<pre>   my_run = yt.load_run("hotgasflow/DD0040/DD0040")
</pre>
<p>-And because we have imported from ``yt.mods`` we have access to the +And because we have used ``yt.enable_plugins`` we have access to the</p>
<pre>``load_run`` function defined in our plugin file.
</pre>
<p>+Note that using the plugins file implies that your script is no longer fully +reproducible. If you share your script with someone else and use some of the +functionality if your plugins file, you will also need to share your plugins +file for someone else to re-run your script properly. +</p>
<pre>Adding Custom Colormaps
^^^^^^^^^^^^^^^^^^^^^^^
</pre>
<p>diff -r 299e448d91100b7009f3d95e7ee5409a07cbac9c -r 9fa87cf2500ac6560789c9a58f1f419bb12cbd7c yt/funcs.py --- a/yt/funcs.py +++ b/yt/funcs.py @@ -838,6 +838,17 @@</p>
<pre>    return _func

def enable_plugins():</pre>
<p>+    """Forces the plugins file to be parsed. + +    This plugin file is a means of creating custom fields, quantities, +    data objects, colormaps, and other code classes and objects to be used +    in yt scripts without modifying the yt source directly. + +    The file must be located at ``$HOME/.yt/my_plugins.py``. + +    Warning: when you use this function, your script will only be reproducible +    if you also provide the ``my_plugins.py`` file. +    """</p>
<pre>import yt
from yt.fields.my_plugin_fields import my_plugins_fields
from yt.config import ytcfg</pre>
<p>Repository URL: <a href="https://bitbucket.org/yt_analysis/yt/">https://bitbucket.org/yt_analysis/yt/</a></p>
<p>—</p>
<p>This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.</p>

<img src="http://link.bitbucket.org/wf/open?upn=ll4ctv0L-2ByeRZFC1LslHcg6aJmnQ70VruLbmeLQr27BMgoFbLPCQdy43yEjRfK5u58C3SmvVm-2F0yj1d3MoUbtSLnqwyao5h-2FdKxSqmu60VPcY-2FdtavHhApf1eMVRlrKLihl82258HpeoqRDTlZM77DVmI2Hqaa6MdFMxZhLahKb8jm1kruBu1OMqaljmq2Ut1sU4knQ7ouCPXEXPJFuP-2FH-2B4ICVVeRAkrEMf-2FET2dpI-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;"/>
</body></html>