diff options
author | Harsh Mishra <erbeusgriffincasper@gmail.com> | 2021-05-19 03:45:54 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-18 18:15:54 -0400 |
commit | 45bd170c5493347f38616fc3ecbab55fb615a91b (patch) | |
tree | a856070df4bb36c13088ab9ef7c8e2ef62682cff | |
parent | 5658cb92197cc497520b3438a9d282f5d56a7217 (diff) | |
download | networkx-45bd170c5493347f38616fc3ecbab55fb615a91b.tar.gz |
Use `callable()` to check if the object is calllable (#1) (#4678)
Co-authored-by: erbeusgriffincasper@gmail.com
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
-rw-r--r-- | networkx/drawing/nx_agraph.py | 2 | ||||
-rw-r--r-- | networkx/linalg/attrmatrix.py | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/networkx/drawing/nx_agraph.py b/networkx/drawing/nx_agraph.py index ad2a79ea..0e3d3897 100644 --- a/networkx/drawing/nx_agraph.py +++ b/networkx/drawing/nx_agraph.py @@ -398,7 +398,7 @@ def view_pygraphviz( # If the user passed in an edgelabel, we update the labels for all edges. if edgelabel is not None: - if not hasattr(edgelabel, "__call__"): + if not callable(edgelabel): def func(data): return "".join([" ", str(data[edgelabel]), " "]) diff --git a/networkx/linalg/attrmatrix.py b/networkx/linalg/attrmatrix.py index ffa6fa5b..6d9eab6d 100644 --- a/networkx/linalg/attrmatrix.py +++ b/networkx/linalg/attrmatrix.py @@ -34,7 +34,7 @@ def _node_value(G, node_attr): def value(u): return u - elif not hasattr(node_attr, "__call__"): + elif not callable(node_attr): # assume it is a key for the node attribute dictionary def value(u): return G.nodes[u][node_attr] @@ -94,7 +94,7 @@ def _edge_value(G, edge_attr): def value(u, v): return 1 - elif not hasattr(edge_attr, "__call__"): + elif not callable(edge_attr): # assume it is a key for the edge attribute dictionary if edge_attr == "weight": |