From 0659fe2beac3c77eded2e0da407b6c9d0b870276 Mon Sep 17 00:00:00 2001
From: Joseph Weston <joseph.weston@cea.fr>
Date: Fri, 7 Aug 2015 19:15:29 +0200
Subject: [PATCH] replace true-division with proper floor-division

Also, replace redundant check against Callable abc
with builtin `callable` function.
---
 kwant/plotter.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kwant/plotter.py b/kwant/plotter.py
index a2495d5d..22bd311c 100644
--- a/kwant/plotter.py
+++ b/kwant/plotter.py
@@ -947,7 +947,7 @@ def sys_leads_hopping_pos(sys, hop_lead_nr):
     for k, v in vecs_doms.items():
         vecs_doms[k] = [v[0] * i for i in range(v[1], v[1] + num_lead_cells)]
     pos += [vecs_doms[i[1]][i[2]] for i in hop_lead_nr]
-    return np.copy(pos[:, : dim / 2]), np.copy(pos[:, dim / 2:])
+    return np.copy(pos[:, : dim // 2]), np.copy(pos[:, dim // 2:])
 
 
 # Useful plot functions (to be extended).
@@ -1195,7 +1195,7 @@ def plot(sys, num_lead_cells=2, unit='nn',
 
     # make all specs proper: either constant or lists/np.arrays:
     def make_proper_site_spec(spec, fancy_indexing=False):
-        if isinstance(spec, collections.Callable):
+        if callable(spec):
             spec = [spec(i[0]) for i in sites if i[1] is None]
         if (fancy_indexing and isarray(spec)
             and not isinstance(spec, np.ndarray)):
@@ -1206,7 +1206,7 @@ def plot(sys, num_lead_cells=2, unit='nn',
         return spec
 
     def make_proper_hop_spec(spec, fancy_indexing=False):
-        if isinstance(spec, collections.Callable):
+        if callable(spec):
             spec = [spec(*i[0]) for i in hops if i[1] is None]
         if (fancy_indexing and isarray(spec)
             and not isinstance(spec, np.ndarray)):
@@ -1537,7 +1537,7 @@ def map(sys, value, colorbar=True, cmap=None, vmin=None, vmax=None, a=None,
     if coords.shape[1] != 2:
         raise ValueError('Only 2D systems can be plotted this way.')
 
-    if isinstance(value, collections.Callable):
+    if callable(value):
         value = [value(site[0]) for site in sites]
     else:
         if not isinstance(sys, system.FiniteSystem):
-- 
GitLab