[yt-svn] commit/yt: bwkeller: Merged in MatthewTurk/yt (pull request #1888)

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Nov 30 11:13:21 PST 2015


1 new commit in yt:

https://bitbucket.org/yt_analysis/yt/commits/66152c77e32c/
Changeset:   66152c77e32c
Branch:      yt
User:        bwkeller
Date:        2015-11-30 19:12:59+00:00
Summary:     Merged in MatthewTurk/yt (pull request #1888)

Implement ptp operation.
Affected #:  2 files

diff -r 0ba5b60db61ce63dfdd2c58ebaa4b14b19e16f03 -r 66152c77e32c81c8bce0506a67f9a192302f8623 yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -712,7 +712,27 @@
         raise NotImplementedError
 
     def ptp(self, field):
-        raise NotImplementedError
+        r"""Compute the range of values (maximum - minimum) of a field.
+
+        This will, in a parallel-aware fashion, compute the "peak-to-peak" of
+        the given field.
+
+        Parameters
+        ----------
+        field : string or tuple of strings
+            The field to average.
+
+        Returns
+        -------
+        Scalar
+
+        Examples
+        --------
+
+        >>> rho_range = reg.ptp("density")
+        """
+        ex = self._compute_extrema(field)
+        return ex[1] - ex[0]
 
     def hist(self, field, weight = None, bins = None):
         raise NotImplementedError

diff -r 0ba5b60db61ce63dfdd2c58ebaa4b14b19e16f03 -r 66152c77e32c81c8bce0506a67f9a192302f8623 yt/data_objects/tests/test_numpy_ops.py
--- a/yt/data_objects/tests/test_numpy_ops.py
+++ b/yt/data_objects/tests/test_numpy_ops.py
@@ -73,6 +73,9 @@
         q = ad.max("density").v
         yield assert_equal, q, ad["density"].max()
 
+        ptp = ad.ptp("density").v
+        yield assert_equal, ptp, ad["density"].max() - ad["density"].min()
+
         p = ad.max("density", axis=1)
         p1 = ds.proj("density", 1, data_source=ad, method="mip")
         yield assert_equal, p["density"], p1["density"]

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