diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 740ccc60ac4b41751d379d5b7c70f4c691acd8b1..ee2257104f50e9f0ecad80210b108039c31bb4e2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -78,7 +78,7 @@ build PDF documentation: run tests: stage: test script: - - py.test --cov=kwant --cov-report term --cov-report html --flakes kwant + - py.test -r w --cov=kwant --cov-report term --cov-report html --flakes kwant artifacts: paths: - htmlcov diff --git a/kwant/continuum/tests/test_common.py b/kwant/continuum/tests/test_common.py index 298495c9cb98b068d592fef453f9b2c5e9cee53d..34981d6943dceb2a1cc020aa3fe76d1300b93faf 100644 --- a/kwant/continuum/tests/test_common.py +++ b/kwant/continuum/tests/test_common.py @@ -185,5 +185,12 @@ def test_lambdify_substitutions(e, kwargs): should_be = lambda x, y, z: x + y + z subs = {'y': 'y + z'} - e = lambdify(e, locals=subs) + if not isinstance(e, str): + # warns that 'locals' are not used if 'e' is + # a sympy expression already + with pytest.warns(RuntimeWarning): + e = lambdify(e, locals=subs) + else: + e = lambdify(e, locals=subs) + assert e(**kwargs) == should_be(**kwargs) diff --git a/kwant/plotter.py b/kwant/plotter.py index e64f032ba3254d31ed09fc34cdaeb92bee165c7e..c6933789fcfa8fbd7e7c543d49c35f3b4285b919 100644 --- a/kwant/plotter.py +++ b/kwant/plotter.py @@ -1770,8 +1770,13 @@ def spectrum(syst, x, y=None, params=None, mask=None, file=None, if fig_size is not None: fig.set_figwidth(fig_size[0]) fig.set_figheight(fig_size[1]) - projection = '3d' if y is not None else None - ax = fig.add_subplot(1, 1, 1, projection=projection) + if y is None: + ax = fig.add_subplot(1, 1, 1) + else: + warnings.filterwarnings('ignore', + message=r'.*mouse rotation disabled.*') + ax = fig.add_subplot(1, 1, 1, projection='3d') + warnings.resetwarnings() ax.set_xlabel(keys[0]) if y is None: ax.set_ylabel('Energy') diff --git a/kwant/tests/test_builder.py b/kwant/tests/test_builder.py index 9bd369d66a3154ea1406abd013e6c7fb2110127d..9c83ac594e698fac82f36bdb63e1197acb25035b 100644 --- a/kwant/tests/test_builder.py +++ b/kwant/tests/test_builder.py @@ -715,6 +715,7 @@ def test_fill(): target = builder.Builder() added_sites = target.fill(template_1d, line_200, g(0, 0)) assert len(added_sites) == 200 + # raise warning if target already contains all starting sites with warns(RuntimeWarning): target.fill(template_1d, line_200, g(0, 0)) diff --git a/kwant/tests/test_plotter.py b/kwant/tests/test_plotter.py index 84a3a5c6ab8cc918486e0d1e83d275157f198b6c..11266b4e8e167a46acdb40cb9fcd286c9f74de8f 100644 --- a/kwant/tests/test_plotter.py +++ b/kwant/tests/test_plotter.py @@ -71,13 +71,10 @@ def syst_2d(W=3, r1=3, r2=8): syst[lat.neighbors()] = -t sym_lead0 = kwant.TranslationalSymmetry(lat.vec((-1, 0))) lead0 = kwant.Builder(sym_lead0) - lead2 = kwant.Builder(sym_lead0) lead_shape = lambda pos: (-W / 2 < pos[1] < W / 2) lead0[lat.shape(lead_shape, (0, 0))] = 4 * t - lead2[lat.shape(lead_shape, (0, 0))] = 4 * t - syst.attach_lead(lead2) lead0[lat.neighbors()] = - t lead1 = lead0.reversed() syst.attach_lead(lead0) @@ -123,8 +120,7 @@ def test_plot(): if (color != 'k' and isinstance(color(next(iter(syst2d.sites()))), float)): assert fig.axes[0].collections[0].get_array() is not None - assert len(fig.axes[0].collections) == (8 if syst is syst2d else - 6) + assert len(fig.axes[0].collections) == 6 color_opts = ['k', (lambda site, site2: site.tag[0]), lambda site, site2: (abs(site.tag[0] / 100), abs(site.tag[1] / 100), 0)] diff --git a/kwant/tests/test_wraparound.py b/kwant/tests/test_wraparound.py index 18585275895f7d4c34f91c86868139ed3a1dc505..dc8ed3a927ea2248d4991d856b9f00310b812474 100644 --- a/kwant/tests/test_wraparound.py +++ b/kwant/tests/test_wraparound.py @@ -271,8 +271,8 @@ def test_fd_mismatch(): # combine the previous two syst3 = kwant.Builder(T) - syst3 += syst1 - syst3 += syst2 + syst3.update(syst1) + syst3.update(syst2) for syst in (syst1, syst2, syst3): wraparound(syst)