[yt-svn] commit/yt: 3 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Tue Aug 12 12:21:50 PDT 2014
3 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/1818b7e20aab/
Changeset: 1818b7e20aab
Branch: yt
User: MatthewTurk
Date: 2014-08-12 16:24:39
Summary: Adding a _debug() command to enable debugging derived fields.
Affected #: 2 files
diff -r d5b14180936148e2400ac1c495f429b8d58ba62b -r 1818b7e20aabc83a2113d29a17e5ce0c21daad7a yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -129,6 +129,15 @@
self._index = self.ds.index
return self._index
+ def _debug(self):
+ """
+ When called from within a derived field, this will run pdb. However,
+ during field detection, it will not. This allows you to more easily
+ debug fields that are being called on actual objects.
+ """
+ import pdb
+ pdb.set_trace()
+
def _set_default_field_parameters(self):
self.field_parameters = {}
for k,v in self._default_field_parameters.items():
diff -r d5b14180936148e2400ac1c495f429b8d58ba62b -r 1818b7e20aabc83a2113d29a17e5ce0c21daad7a yt/fields/field_detector.py
--- a/yt/fields/field_detector.py
+++ b/yt/fields/field_detector.py
@@ -148,6 +148,10 @@
self[item] = self._read_data(item)
return self[item]
+ def _debug(self):
+ # We allow this to pass through.
+ return
+
def deposit(self, *args, **kwargs):
return np.random.random((self.nd, self.nd, self.nd))
https://bitbucket.org/yt_analysis/yt/commits/bebbdc2499cf/
Changeset: bebbdc2499cf
Branch: yt
User: MatthewTurk
Date: 2014-08-12 16:26:47
Summary: Adding docs for data._debug().
Affected #: 1 file
diff -r 1818b7e20aabc83a2113d29a17e5ce0c21daad7a -r bebbdc2499cfad30295f5418430bdb64aea9ccf0 doc/source/developing/creating_derived_fields.rst
--- a/doc/source/developing/creating_derived_fields.rst
+++ b/doc/source/developing/creating_derived_fields.rst
@@ -179,6 +179,18 @@
fields or that get aliased to themselves, we can specify a different
desired output unit than the unit found on disk.
+Debugging a Derived Field
+-------------------------
+
+If your derived field is not behaving as you would like, you can insert a call
+to ``data._debug()`` to spawn an interactive interpreter whenever that line is
+reached. Note that this is slightly different from calling
+``pdb.set_trace()``, as it will *only* trigger when the derived field is being
+called on an actual data object, rather than during the field detection phase.
+The starting position will be one function lower in the stack than you are
+likely interested in, but you can either step through back to the derived field
+function, or simply type ``u`` to go up a level in the stack.
+
Units for Cosmological Datasets
-------------------------------
https://bitbucket.org/yt_analysis/yt/commits/54d537d85880/
Changeset: 54d537d85880
Branch: yt
User: MatthewTurk
Date: 2014-08-12 21:12:11
Summary: Adding example.
Affected #: 1 file
diff -r bebbdc2499cfad30295f5418430bdb64aea9ccf0 -r 54d537d8588063c31f63b135647a85e3dda3cfe1 doc/source/developing/creating_derived_fields.rst
--- a/doc/source/developing/creating_derived_fields.rst
+++ b/doc/source/developing/creating_derived_fields.rst
@@ -191,6 +191,26 @@
likely interested in, but you can either step through back to the derived field
function, or simply type ``u`` to go up a level in the stack.
+For instance, if you had defined this derived field:
+
+.. code-block:: python
+
+ @yt.derived_field(name = "funthings")
+ def funthings(field, data):
+ return data["sillythings"] + data["humorousthings"]**2.0
+
+And you wanted to debug it, you could do:
+
+.. code-block:: python
+
+ @yt.derived_field(name = "funthings")
+ def funthings(field, data):
+ data._debug()
+ return data["sillythings"] + data["humorousthings"]**2.0
+
+And now, when that derived field is actually used, you will be placed into a
+debugger.
+
Units for Cosmological Datasets
-------------------------------
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.
More information about the yt-svn
mailing list