From 1cff8cbf2d076aaa7d0b7f54f4237bbcaee78a61 Mon Sep 17 00:00:00 2001
From: Joseph Weston <joseph@weston.cloud>
Date: Wed, 12 Jun 2019 10:28:06 +0200
Subject: [PATCH] add a test to disallow arrays with kwant.Builder

---
 kwant/tests/test_plotter.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/kwant/tests/test_plotter.py b/kwant/tests/test_plotter.py
index 5974d893..a8358284 100644
--- a/kwant/tests/test_plotter.py
+++ b/kwant/tests/test_plotter.py
@@ -169,6 +169,21 @@ def test_plot_more_site_families_than_colors():
         plotter.plot(syst, file=out)
 
 
+@pytest.mark.skipif(not _plotter.mpl_available, reason="Matplotlib unavailable.")
+def test_plot_raises_on_bad_site_spec():
+    syst = kwant.Builder()
+    lat = kwant.lattice.square()
+    syst[(lat(i, j) for i in range(5) for j in range(5))] = None
+
+    # Cannot provide site_size as an array when syst is a Builder
+    with pytest.raises(TypeError):
+        plotter.plot(syst, site_size=[1] * 25)
+
+    # Cannot provide site_size as an array when syst is a Builder
+    with pytest.raises(TypeError):
+        plotter.plot(syst, site_symbol=['o'] * 25)
+
+
 def good_transform(pos):
     x, y = pos
     return y, x
-- 
GitLab