[yt-svn] commit/yt: 5 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Wed Aug 9 14:07:36 PDT 2017


5 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/9a33194b5964/
Changeset:   9a33194b5964
User:        John McCann
Date:        2017-07-19 23:19:32+00:00
Summary:     dbug: fixes symlog minor ticks when extrema of data is zero

(symlog_zeroes/): Remove the bug when the values in user's data
set have either data.min() or data.max() equal to zero. Was
passing zero into get_log_minorticks() from
get_symlog_minorticks() and taking np.log10(0). With new catches
can properly account for this situtation.
Affected #:  1 file

diff -r b409ebd065a228e75b1e1a6b602eaaab799bdf03 -r 9a33194b596490ab614eda13016ddfa8fd1e8f6b yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -142,8 +142,12 @@
         the maximum value in the colorbar
 
     """
-    if vmin >= 0 or vmax <= 0:
+    if vmin > 0 or vmax < 0:
         return get_log_minorticks(vmin, vmax)
+    elif vmin == 0:
+        return np.hstack( (0, get_log_minorticks(linthresh, vmax)) )
+    elif vmax == 0:
+        return np.hstack( (-get_log_minorticks(linthresh,-vim)[::-1], 0) )
     else:
         return np.hstack( (-get_log_minorticks(linthresh,-vmin)[::-1], 0,
                             get_log_minorticks(linthresh, vmax)) )


https://bitbucket.org/yt_analysis/yt/commits/dc53ad8eef7b/
Changeset:   dc53ad8eef7b
User:        John McCann
Date:        2017-07-19 23:33:53+00:00
Summary:     dbug: fixes symlog major ticks when extrema of data is zero

(symlog_zeroes/): Remove the bug when the values in user's data
set have either data.min() or data.max() equal to zero. Was
taking np.log10(0). With new catches can properly account for
this situtation.

fixes #1501
Affected #:  1 file

diff -r 9a33194b596490ab614eda13016ddfa8fd1e8f6b -r dc53ad8eef7b72d5acd94b09716fb6eeff734c42 yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -229,7 +229,15 @@
                 **formatter_kwargs)
             self.cb = self.figure.colorbar(
                 self.image, self.cax, format=formatter)
-            yticks = list(-10**np.arange(np.floor(np.log10(-data.min())),\
+            if data.min().v >= 0.0:
+                yticks = [data.min().v] + list(10**np.arange(
+                                          np.rint(np.log10(cblinthresh)),\
+                          np.ceil(np.log10(data.max()))+1))
+            elif data.max().v <= 0.0:
+                yticks = list(-10**np.arange(np.floor(np.log10(-data.min())),\
+                         np.rint(np.log10(cblinthresh))-1, -1)) + [data.max().v]
+            else:
+                yticks = list(-10**np.arange(np.floor(np.log10(-data.min())),\
                           np.rint(np.log10(cblinthresh))-1, -1)) + [0] + \
                      list(10**np.arange(np.rint(np.log10(cblinthresh)),\
                           np.ceil(np.log10(data.max()))+1))


https://bitbucket.org/yt_analysis/yt/commits/b9ddf23abe5b/
Changeset:   b9ddf23abe5b
User:        ngoldbaum
Date:        2017-08-07 18:35:00+00:00
Summary:     minor formatting adjustments
Affected #:  2 files

diff -r dc53ad8eef7b72d5acd94b09716fb6eeff734c42 -r b9ddf23abe5b66ec59247cad62ecb2a4e75074fc yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -229,18 +229,23 @@
                 **formatter_kwargs)
             self.cb = self.figure.colorbar(
                 self.image, self.cax, format=formatter)
-            if data.min().v >= 0.0:
-                yticks = [data.min().v] + list(10**np.arange(
-                                          np.rint(np.log10(cblinthresh)),\
-                          np.ceil(np.log10(data.max()))+1))
-            elif data.max().v <= 0.0:
-                yticks = list(-10**np.arange(np.floor(np.log10(-data.min())),\
-                         np.rint(np.log10(cblinthresh))-1, -1)) + [data.max().v]
+            if data.min() >= 0.0:
+                yticks = [data.min().v] + list(
+                    10**np.arange(np.rint(np.log10(cblinthresh)),
+                                  np.ceil(np.log10(data.max())) + 1))
+            elif data.max() <= 0.0:
+                yticks = list(
+                    -10**np.arange(
+                        np.floor(np.log10(-data.min())),
+                        np.rint(np.log10(cblinthresh)) - 1, -1)) + \
+                    [data.max().v]
             else:
-                yticks = list(-10**np.arange(np.floor(np.log10(-data.min())),\
-                          np.rint(np.log10(cblinthresh))-1, -1)) + [0] + \
-                     list(10**np.arange(np.rint(np.log10(cblinthresh)),\
-                          np.ceil(np.log10(data.max()))+1))
+                yticks = list(
+                    -10**np.arange(np.floor(np.log10(-data.min())),
+                                   np.rint(np.log10(cblinthresh))-1, -1)) + \
+                    [0] + \
+                    list(10**np.arange(np.rint(np.log10(cblinthresh)),
+                                       np.ceil(np.log10(data.max()))+1))
             self.cb.set_ticks(yticks)
         else:
             self.cb = self.figure.colorbar(self.image, self.cax)

diff -r dc53ad8eef7b72d5acd94b09716fb6eeff734c42 -r b9ddf23abe5b66ec59247cad62ecb2a4e75074fc yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -145,12 +145,12 @@
     if vmin > 0 or vmax < 0:
         return get_log_minorticks(vmin, vmax)
     elif vmin == 0:
-        return np.hstack( (0, get_log_minorticks(linthresh, vmax)) )
+        return np.hstack((0, get_log_minorticks(linthresh, vmax)))
     elif vmax == 0:
-        return np.hstack( (-get_log_minorticks(linthresh,-vim)[::-1], 0) )
+        return np.hstack((-get_log_minorticks(linthresh,-vmin)[::-1], 0) )
     else:
-        return np.hstack( (-get_log_minorticks(linthresh,-vmin)[::-1], 0,
-                            get_log_minorticks(linthresh, vmax)) )
+        return np.hstack((-get_log_minorticks(linthresh,-vmin)[::-1], 0,
+                          get_log_minorticks(linthresh, vmax)))
 
 field_transforms = {}
 


https://bitbucket.org/yt_analysis/yt/commits/b1a54180c651/
Changeset:   b1a54180c651
User:        ngoldbaum
Date:        2017-08-07 18:45:33+00:00
Summary:     add test for symlog scaling
Affected #:  1 file

diff -r b9ddf23abe5b66ec59247cad62ecb2a4e75074fc -r b1a54180c651d5b41afc7b5ee6c3942d2f04ef1f yt/visualization/tests/test_plotwindow.py
--- a/yt/visualization/tests/test_plotwindow.py
+++ b/yt/visualization/tests/test_plotwindow.py
@@ -525,3 +525,26 @@
     slc = SlicePlot(ds, "theta", ["density"], width=(30000.0, "km"))
     slc2 = plot_2d(ds, "density", width=(30000.0, "km"))
     assert_array_equal(slc.frb['density'], slc2.frb['density'])
+
+def test_symlog_colorbar():
+    ds = fake_random_ds(16)
+
+    def _thresh_density(field, data):
+        wh = data['density'] < 0.5
+        ret = data['density']
+        ret[wh] = 0
+        return ret
+
+    def _neg_density(field, data):
+        return -data['threshold_density']
+
+    ds.add_field('threshold_density', function=_thresh_density,
+                 units='g/cm**3', sampling_type='cell')
+    ds.add_field('negative_density', function=_neg_density, units='g/cm**3',
+                 sampling_type='cell')
+
+    for field in ['density', 'threshold_density', 'negative_density']:
+        plot = SlicePlot(ds, 2, field)
+        plot.set_log(field, True, linthresh=0.1)
+        with tempfile.NamedTemporaryFile(suffix='png') as f:
+            plot.save(f.name)


https://bitbucket.org/yt_analysis/yt/commits/68d50c94be9a/
Changeset:   68d50c94be9a
User:        ngoldbaum
Date:        2017-08-09 21:07:15+00:00
Summary:     Merge pull request #1502 from JohnMcCann/symlog_zeroes

Symlog zeroes catches passed to np.log10()
Affected #:  3 files

diff -r c72d9bee3e75791d6882a9763119016b88c22ff8 -r 68d50c94be9a88927df18b72b202167dd4a3696d yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -229,10 +229,23 @@
                 **formatter_kwargs)
             self.cb = self.figure.colorbar(
                 self.image, self.cax, format=formatter)
-            yticks = list(-10**np.arange(np.floor(np.log10(-data.min())),\
-                          np.rint(np.log10(cblinthresh))-1, -1)) + [0] + \
-                     list(10**np.arange(np.rint(np.log10(cblinthresh)),\
-                          np.ceil(np.log10(data.max()))+1))
+            if data.min() >= 0.0:
+                yticks = [data.min().v] + list(
+                    10**np.arange(np.rint(np.log10(cblinthresh)),
+                                  np.ceil(np.log10(data.max())) + 1))
+            elif data.max() <= 0.0:
+                yticks = list(
+                    -10**np.arange(
+                        np.floor(np.log10(-data.min())),
+                        np.rint(np.log10(cblinthresh)) - 1, -1)) + \
+                    [data.max().v]
+            else:
+                yticks = list(
+                    -10**np.arange(np.floor(np.log10(-data.min())),
+                                   np.rint(np.log10(cblinthresh))-1, -1)) + \
+                    [0] + \
+                    list(10**np.arange(np.rint(np.log10(cblinthresh)),
+                                       np.ceil(np.log10(data.max()))+1))
             self.cb.set_ticks(yticks)
         else:
             self.cb = self.figure.colorbar(self.image, self.cax)

diff -r c72d9bee3e75791d6882a9763119016b88c22ff8 -r 68d50c94be9a88927df18b72b202167dd4a3696d yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -142,11 +142,15 @@
         the maximum value in the colorbar
 
     """
-    if vmin >= 0 or vmax <= 0:
+    if vmin > 0 or vmax < 0:
         return get_log_minorticks(vmin, vmax)
+    elif vmin == 0:
+        return np.hstack((0, get_log_minorticks(linthresh, vmax)))
+    elif vmax == 0:
+        return np.hstack((-get_log_minorticks(linthresh,-vmin)[::-1], 0) )
     else:
-        return np.hstack( (-get_log_minorticks(linthresh,-vmin)[::-1], 0,
-                            get_log_minorticks(linthresh, vmax)) )
+        return np.hstack((-get_log_minorticks(linthresh,-vmin)[::-1], 0,
+                          get_log_minorticks(linthresh, vmax)))
 
 field_transforms = {}
 

diff -r c72d9bee3e75791d6882a9763119016b88c22ff8 -r 68d50c94be9a88927df18b72b202167dd4a3696d yt/visualization/tests/test_plotwindow.py
--- a/yt/visualization/tests/test_plotwindow.py
+++ b/yt/visualization/tests/test_plotwindow.py
@@ -525,3 +525,26 @@
     slc = SlicePlot(ds, "theta", ["density"], width=(30000.0, "km"))
     slc2 = plot_2d(ds, "density", width=(30000.0, "km"))
     assert_array_equal(slc.frb['density'], slc2.frb['density'])
+
+def test_symlog_colorbar():
+    ds = fake_random_ds(16)
+
+    def _thresh_density(field, data):
+        wh = data['density'] < 0.5
+        ret = data['density']
+        ret[wh] = 0
+        return ret
+
+    def _neg_density(field, data):
+        return -data['threshold_density']
+
+    ds.add_field('threshold_density', function=_thresh_density,
+                 units='g/cm**3', sampling_type='cell')
+    ds.add_field('negative_density', function=_neg_density, units='g/cm**3',
+                 sampling_type='cell')
+
+    for field in ['density', 'threshold_density', 'negative_density']:
+        plot = SlicePlot(ds, 2, field)
+        plot.set_log(field, True, linthresh=0.1)
+        with tempfile.NamedTemporaryFile(suffix='png') as f:
+            plot.save(f.name)

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