From 2eb21c469f74ed771e9560e42f176fce764aeda1 Mon Sep 17 00:00:00 2001 From: Pol Febrer Date: Thu, 4 Nov 2021 12:07:30 +0100 Subject: [PATCH] bug: Plot was not callable --- sisl/viz/_plotables.py | 2 +- sisl/viz/tests/fort.1000 | 0 sisl/viz/tests/test_plot.py | 9 ++++++++- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 sisl/viz/tests/fort.1000 diff --git a/sisl/viz/_plotables.py b/sisl/viz/_plotables.py index addef20eb7..eb53566bae 100644 --- a/sisl/viz/_plotables.py +++ b/sisl/viz/_plotables.py @@ -24,7 +24,7 @@ class ObjectPlotHandler(ObjectDispatcher): def __call__(self, *args, **kwargs): """If the plot handler is called, we will run the default plotting function unless the keyword method has been passed.""" - return getattr(self, kwargs.pop("method", self._default))(*args, **kwargs) + return getattr(self, kwargs.pop("method", self._default) or self._default)(*args, **kwargs) class PlotDispatch(AbstractDispatch): diff --git a/sisl/viz/tests/fort.1000 b/sisl/viz/tests/fort.1000 new file mode 100644 index 0000000000..e69de29bb2 diff --git a/sisl/viz/tests/test_plot.py b/sisl/viz/tests/test_plot.py index 7563f78043..8a98a1d1a8 100644 --- a/sisl/viz/tests/test_plot.py +++ b/sisl/viz/tests/test_plot.py @@ -8,7 +8,7 @@ """ from copy import deepcopy import os -from sisl.messages import SislWarning +from sisl.messages import SislInfo, SislWarning import pytest import numpy as np @@ -224,3 +224,10 @@ def test_subplots_arrangement(self): class _TestAnimation(TestMultiplePlot): PlotClass = Animation + +def test_calling_Plot(): + # Just check that it doesn't raise any error + with pytest.warns(SislInfo): + plot = Plot("nonexistent.LDOS") + + assert isinstance(plot, GridPlot) \ No newline at end of file