From 8aa8f574741f3e6fedce727a7fe39af87409c97a Mon Sep 17 00:00:00 2001
From: Anton Akhmerov <anton.akhmerov@gmail.com>
Date: Mon, 11 Feb 2019 23:18:43 +0100
Subject: [PATCH] use correct coordinate reshaping when determining a plot
 reference length

Also correctly select random sites without repetitions.
Closes issue #265.
---
 kwant/plotter.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kwant/plotter.py b/kwant/plotter.py
index 1af73aec..4652271c 100644
--- a/kwant/plotter.py
+++ b/kwant/plotter.py
@@ -43,7 +43,7 @@ _p = _common.lazy_import('_plotter')
 def _sample_array(array, n_samples, rng=None):
     rng = _common.ensure_rng(rng)
     la = len(array)
-    return array[rng.choice(range(la), min(n_samples, la))]
+    return array[rng.choice(range(la), min(n_samples, la), replace=False)]
 
 
 # matplotlib helper functions.
@@ -891,7 +891,7 @@ def plot(sys, num_lead_cells=2, unit='nn',
             # from ten randomly selected points to the remaining points in the
             # system.
             points = _sample_array(sites_pos, 10).T
-            distances = (sites_pos.T.reshape(1, -1, dim) -
+            distances = (sites_pos.reshape(1, -1, dim) -
                          points.reshape(-1, 1, dim)).reshape(-1, dim)
         distances = np.sort(np.sum(distances**2, axis=1))
         # Then check if distances are present that are way shorter than the
-- 
GitLab