diff options
| author | Jarrod Millman <jarrod.millman@gmail.com> | 2017-09-09 20:21:22 -0700 |
|---|---|---|
| committer | Jarrod Millman <jarrod.millman@gmail.com> | 2017-09-09 23:54:14 -0700 |
| commit | e290acc44a1236ad49b1a62a9531ffcab7ce62fa (patch) | |
| tree | c74b5f13aab4639b5db30bce3e4ff8e11cbc4cab | |
| parent | ef82a6b15e1475eb587caf18d582b4d37ba20327 (diff) | |
| download | networkx-e290acc44a1236ad49b1a62a9531ffcab7ce62fa.tar.gz | |
Remove is_string_like (deprecated for isinstance)
| -rw-r--r-- | networkx/drawing/nx_pylab.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/networkx/drawing/nx_pylab.py b/networkx/drawing/nx_pylab.py index 79dc5ed5..5832b9a7 100644 --- a/networkx/drawing/nx_pylab.py +++ b/networkx/drawing/nx_pylab.py @@ -39,6 +39,13 @@ __all__ = ['draw', 'draw_spring', 'draw_shell'] +# 2.x/3.x compatibility +try: + basestring +except NameError: + basestring = str + unicode = str + def draw(G, pos=None, ax=None, **kwds): """Draw the graph G with Matplotlib. @@ -519,17 +526,15 @@ def draw_networkx_edges(G, pos, else: lw = width - if not cb.is_string_like(edge_color) \ + if not isinstance(edge_color, basestring) \ and cb.iterable(edge_color) \ and len(edge_color) == len(edge_pos): - if np.alltrue([cb.is_string_like(c) - for c in edge_color]): + if np.alltrue([isinstance(c, basestring) for c in edge_color]): # (should check ALL elements) # list of color letters such as ['k','r','k',...] edge_colors = tuple([colorConverter.to_rgba(c, alpha) for c in edge_color]) - elif np.alltrue([not cb.is_string_like(c) - for c in edge_color]): + elif np.alltrue([not isinstance(c, basestring) for c in edge_color]): # If color specs are given as (rgb) or (rgba) tuples, we're OK if np.alltrue([cb.iterable(c) and len(c) in (3, 4) for c in edge_color]): @@ -540,7 +545,7 @@ def draw_networkx_edges(G, pos, else: raise ValueError('edge_color must consist of either color names or numbers') else: - if cb.is_string_like(edge_color) or len(edge_color) == 1: + if isinstance(edge_color, basestring) or len(edge_color) == 1: edge_colors = (colorConverter.to_rgba(edge_color, alpha), ) else: raise ValueError( @@ -721,7 +726,7 @@ def draw_networkx_labels(G, pos, text_items = {} # there is no text collection so we'll fake one for n, label in labels.items(): (x, y) = pos[n] - if not cb.is_string_like(label): + if not isinstance(label, basestring): label = str(label) # this will cause "1" and 1 to be labeled the same t = ax.text(x, y, label, @@ -859,7 +864,7 @@ def draw_networkx_edge_labels(G, pos, ec=(1.0, 1.0, 1.0), fc=(1.0, 1.0, 1.0), ) - if not cb.is_string_like(label): + if not isinstance(label, basestring): label = str(label) # this will cause "1" and 1 to be labeled the same # set optional alignment |
