diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9d0e4c4db6cbdb0749800a4a6f948b9699bd43a7..6bbc3efd25699a813a3252b6c7b0da9b0a65dfac 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -69,7 +69,7 @@ run tests: stage: test script: - pip3 install sympy - - 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 2c9fc813d677827505f9b0e476d54dfbc7740751..820286ed2b83d7a1e861e3178bcbe68fafe8b750 100644 --- a/kwant/plotter.py +++ b/kwant/plotter.py @@ -1771,8 +1771,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 b31c0dc09cf18cf96099aac1e69e33ebaf23b0c3..bd8a49c3339b5dd763e263b6d57bc08cdeb5e3e8 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 4619116d990ebe2516c695e4982c63e907be607c..88359b195eee51ecbeb495b5187f9244ac299460 100644 --- a/kwant/tests/test_plotter.py +++ b/kwant/tests/test_plotter.py @@ -59,13 +59,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) @@ -111,8 +108,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 c1233a97cb71aef6e31b240bac616081b6089f0d..315c8c54df2199942d4530ab873dc2e16297372a 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)