<html><body>
<p>1 new commit in yt:</p>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/8f91fd732959/">https://bitbucket.org/yt_analysis/yt/commits/8f91fd732959/</a> Changeset:   8f91fd732959 Branch:      yt User:        ngoldbaum Date:        2016-04-20 18:14:30+00:00 Summary:     Merged in ngoldbaum/yt (pull request #2118)</p>
<p>Add get_brewer_cmap to get brewer colormaps without importing palettable at the top level Affected #:  3 files</p>
<p>diff -r 454b81690191c4ee1c28f0120f39bf9ee99840ed -r 8f91fd7329595d87b927cec203b1246b1de963f9 yt/funcs.py --- a/yt/funcs.py +++ b/yt/funcs.py @@ -930,3 +930,26 @@</p>
<pre>        pbar.finish()

    return hasher.hexdigest()</pre>
<p>+ +def get_brewer_cmap(cmap): +    """Returns a colorbrewer colormap from palettable""" +    try: +        import brewer2mpl +    except ImportError: +        brewer2mpl = None +    try: +        import palettable +    except ImportError: +        palettable = None +    if palettable is not None: +        bmap = palettable.colorbrewer.get_map(*cmap) +    elif brewer2mpl is not None: +        warnings.warn("Using brewer2mpl colormaps is deprecated. " +                      “Please install the successor to brewer2mpl, " +                      “palettable, with `pip install palettable`. " +                      "Colormap tuple names remain unchanged.”) +        bmap = brewer2mpl.get_map(*cmap) +    else: +        raise RuntimeError( +            "Please install palettable to use colorbrewer colormaps”) +    return bmap.get_mpl_colormap(N=cmap[2])</p>
<p>diff -r 454b81690191c4ee1c28f0120f39bf9ee99840ed -r 8f91fd7329595d87b927cec203b1246b1de963f9 yt/visualization/base_plot_types.py --- a/yt/visualization/base_plot_types.py +++ b/yt/visualization/base_plot_types.py @@ -18,19 +18,11 @@</p>
<pre>from ._mpl_imports import \
    FigureCanvasAgg, FigureCanvasPdf, FigureCanvasPS
from yt.funcs import \</pre>
<ul><li><p>get_image_suffix, mylog, iterable</p></li></ul>
<p>+    get_image_suffix, \ +    mylog, \ +    iterable, \ +    get_brewer_cmap</p>
<pre>import numpy as np</pre>
<p>-import warnings -try:</p>
<ul><li><p>import brewer2mpl</p></li>
<li><p>has_brewer = True</p></li></ul>
<p>-except:</p>
<ul><li><p>has_brewer = False</p></li></ul>
<p>-try:</p>
<ul><li><p>import palettable</p></li>
<li><p>has_palettable = True</p></li></ul>
<p>-except:</p>
<ul><li><p>has_palettable = False</p></li></ul>
<pre>class CallbackWrapper(object):</pre>
<p>@@ -135,18 +127,7 @@</p>
<pre>extent = [float(e) for e in extent]
# tuple colormaps are from palettable (or brewer2mpl)
if isinstance(cmap, tuple):</pre>
<ul><li><p>if has_palettable:</p></li>
<li><p>bmap = palettable.colorbrewer.get_map(*cmap)</p></li>
<li><p>elif has_brewer:</p></li>
<li><p>warnings.warn("Using brewer2mpl colormaps is deprecated. "</p></li>
<li><p>"Please install the successor to brewer2mpl, "</p></li>
<li><p>"palettable, with `pip install palettable`. "</p></li>
<li><p>“Colormap tuple names remain unchanged.”)</p></li>
<li><p>bmap = brewer2mpl.get_map(*cmap)</p></li>
<li><p>else:</p></li>
<li><p>raise RuntimeError(</p></li>
<li><p>“Please install palettable to use colorbrewer colormaps”)</p></li>
<li><p>cmap = bmap.get_mpl_colormap(N=cmap[2])</p></li></ul>
<p>+            cmap = get_brewer_cmap(cmap)</p>
<pre>         self.image = self.axes.imshow(data.to_ndarray(), origin='lower',
extent=extent, norm=norm, vmin=self.zmin,
aspect=aspect, vmax=self.zmax, cmap=cmap,</pre>
<p>diff -r 454b81690191c4ee1c28f0120f39bf9ee99840ed -r 8f91fd7329595d87b927cec203b1246b1de963f9 yt/visualization/image_writer.py --- a/yt/visualization/image_writer.py +++ b/yt/visualization/image_writer.py @@ -17,7 +17,10 @@</p>
<pre>from yt.config import \
    ytcfg</pre>
<p>-from yt.funcs import mylog, get_image_suffix +from yt.funcs import \ +    mylog, \ +    get_image_suffix, \ +    get_brewer_cmap</p>
<pre>from yt.units.yt_array import YTQuantity
from yt.utilities.exceptions import YTNotInsideNotebook
from .color_maps import mcm</pre>
<p>@@ -25,17 +28,6 @@</p>
<pre>import yt.utilities.lib.image_utilities as au
import yt.utilities.png_writer as pw
from yt.extern.six.moves import builtins</pre>
<p>-import warnings -try:</p>
<ul><li><p>import palettable</p></li>
<li><p>has_palettable = True</p></li></ul>
<p>-except:</p>
<ul><li><p>has_palettable = False</p></li></ul>
<p>-try:</p>
<ul><li><p>import brewer2mpl</p></li>
<li><p>has_brewer = True</p></li></ul>
<p>-except:</p>
<ul><li><p>has_brewer = False</p></li></ul>
<pre>def scale_image(image, mi=None, ma=None):</pre>
<p>@@ -268,27 +260,17 @@</p>
<pre>         try:
# if cmap is tuple, then we're using palettable or brewer2mpl cmaps
if isinstance(cmap_name, tuple):</pre>
<ul><li><p>if has_palettable:</p></li>
<li><p>bmap = palettable.colorbrewer.get_map(*cmap_name)</p></li>
<li><p>elif has_brewer:</p></li>
<li><p>warnings.warn("Using brewer2mpl colormaps is deprecated. "</p></li>
<li><p>"Please install the successor to brewer2mpl, "</p></li>
<li><p>"palettable, with `pip install palettable`. "</p></li>
<li><p>“Colormap tuple names remain unchanged.”)</p></li>
<li><p>bmap = brewer2mpl.get_map(*cmap_name)</p></li>
<li><p>else:</p></li>
<li><p>raise RuntimeError("Please install palettable to use colorbrewer colormaps")</p></li>
<li><p>cmap = bmap.get_mpl_colormap(N=cmap_name[2])</p></li></ul>
<p>+                cmap = get_brewer_cmap(cmap_name)</p>
<pre>else:
    cmap = mcm.get_cmap(cmap_name)
cmap(0.0)
lut = cmap._lut.T
         except ValueError:</pre>
<ul><li><p>print("Your color map was not found in either the extracted" +\</p></li>
<li><p>" colormap file or matplotlib colormaps")</p></li>
<li><p>raise KeyError(cmap_name)</p></li></ul>
<p>+            raise KeyError( +                “Your color map (%s) was not found in either the extracted” +                " colormap file or matplotlib colormaps" % cmap_name)</p>
<ul><li><p>if isinstance(cmap_name, tuple) and (has_palettable or has_brewer):</p></li></ul>
<p>+    if isinstance(cmap_name, tuple):</p>
<pre># If we are using the colorbrewer maps, don't interpolate
shape = buff.shape
# We add float_eps so that digitize doesn't go out of bounds</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-2ByeRZFC1LslHcg6aJmnQ70VruLbmeLQr27A7Nz71muxvSOfImMzWMj-2FI-2BH0bl1TCkajehKQIe6r3CW1krfYpwi4yPmdp-2BxH1H9e6A40H6eENkfsMeJZIaeihJoWjNWJpb3EreDX1F-2FO-2FQGbwdcmwzPcpVRG5MVzDX6ZtQBZoGf-2Be08FijqbtNdVhMI-2BFWFWzO03VWtQ-2FB0SycUHVUr8Su8agLnBHElJn8Zc-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>