[yt-svn] commit/yt: 2 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Sun Mar 27 14:30:04 PDT 2016
2 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/b06aadf73a03/
Changeset: b06aadf73a03
Branch: yt
User: ngoldbaum
Date: 2016-03-25 03:48:42+00:00
Summary: Documenting the enable_plugins function. Closes #1030.
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
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 @@
~yt.data_objects.static_output.Dataset.box
~yt.funcs.deprecate
~yt.funcs.ensure_list
+ ~yt.funcs.enable_plugins
~yt.funcs.get_pbar
~yt.funcs.humanize_time
~yt.funcs.insert_ipython
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 @@
objects, colormaps, and other code classes and objects to be used in future
yt sessions without modifying the source code directly.
+To force the plugin file to be parsed, call the function
+:func:`~yt.funcs.enable_plugins` at the top of your script.
.. note::
- The ``my_plugins.py`` is only parsed inside of ``yt.mods``, so in order
- to use it, you must load yt with either: ``import yt.mods as yt``
- or ``from yt.mods import *``. 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 invoke ``from yt.mods import *``, so the ``my_plugins.py`` file
- will be parsed if you enter yt that way.
+ 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.
Plugin File Format
^^^^^^^^^^^^^^^^^^
-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
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.
-It is executed at the bottom of ``yt.mods``, and so
-it is provided with the entire namespace available in the module ``yt.mods``.
For example, if I created a plugin file containing:
@@ -152,7 +149,7 @@
return np.random.random(data["density"].shape)
add_field("random", function=_myfunc, units='auto')
-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``.
You can also define other convenience functions in your plugin file. For
instance, you could define some variables or functions, and even import common
@@ -176,13 +173,19 @@
.. code-block:: python
- import yt.mods as yt
+ import yt
+ yt.enable_plugins()
my_run = yt.load_run("hotgasflow/DD0040/DD0040")
-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
``load_run`` function defined in our plugin file.
+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.
+
Adding Custom Colormaps
^^^^^^^^^^^^^^^^^^^^^^^
diff -r a776e67368c5629296b1e365dfca0b68b41ef1d5 -r b06aadf73a03650f3f1ae6395fa4c5522d4675b7 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -838,6 +838,17 @@
return _func
def enable_plugins():
+ """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.
+ """
import yt
from yt.fields.my_plugin_fields import my_plugins_fields
from yt.config import ytcfg
https://bitbucket.org/yt_analysis/yt/commits/9fa87cf2500a/
Changeset: 9fa87cf2500a
Branch: yt
User: MatthewTurk
Date: 2016-03-27 21:29:58+00:00
Summary: Merged in ngoldbaum/yt (pull request #2081)
Documenting the enable_plugins function. Closes #1030.
Affected #: 3 files
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 @@
~yt.data_objects.static_output.Dataset.box
~yt.funcs.deprecate
~yt.funcs.ensure_list
+ ~yt.funcs.enable_plugins
~yt.funcs.get_pbar
~yt.funcs.humanize_time
~yt.funcs.insert_ipython
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 @@
objects, colormaps, and other code classes and objects to be used in future
yt sessions without modifying the source code directly.
+To force the plugin file to be parsed, call the function
+:func:`~yt.funcs.enable_plugins` at the top of your script.
.. note::
- The ``my_plugins.py`` is only parsed inside of ``yt.mods``, so in order
- to use it, you must load yt with either: ``import yt.mods as yt``
- or ``from yt.mods import *``. 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 invoke ``from yt.mods import *``, so the ``my_plugins.py`` file
- will be parsed if you enter yt that way.
+ 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.
Plugin File Format
^^^^^^^^^^^^^^^^^^
-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
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.
-It is executed at the bottom of ``yt.mods``, and so
-it is provided with the entire namespace available in the module ``yt.mods``.
For example, if I created a plugin file containing:
@@ -152,7 +149,7 @@
return np.random.random(data["density"].shape)
add_field("random", function=_myfunc, units='auto')
-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``.
You can also define other convenience functions in your plugin file. For
instance, you could define some variables or functions, and even import common
@@ -176,13 +173,19 @@
.. code-block:: python
- import yt.mods as yt
+ import yt
+ yt.enable_plugins()
my_run = yt.load_run("hotgasflow/DD0040/DD0040")
-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
``load_run`` function defined in our plugin file.
+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.
+
Adding Custom Colormaps
^^^^^^^^^^^^^^^^^^^^^^^
diff -r 299e448d91100b7009f3d95e7ee5409a07cbac9c -r 9fa87cf2500ac6560789c9a58f1f419bb12cbd7c yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -838,6 +838,17 @@
return _func
def enable_plugins():
+ """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.
+ """
import yt
from yt.fields.my_plugin_fields import my_plugins_fields
from yt.config import ytcfg
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-svn-spacepope.org/attachments/20160327/fb1472f8/attachment.html>
More information about the yt-svn
mailing list