To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 5baa9379 authored by Cyrill Mast's avatar Cyrill Mast
Browse files

x and y data are update only when length is equal

parent b00b8762
Pipeline #89056 passed with stages
in 5 minutes and 13 seconds
......@@ -40,13 +40,9 @@ class PlotGeneral:
@x_data.setter
def x_data(self, value):
self._ax_semilogy.lines[0].set_xdata(value)
self._ax_semilogy.set_xlim(
max(1e-80, min(value)), min(max(value), 1e5))
self._ax_complex.lines[0].set_xdata(value)
self._ax_complex.set_xlim(
max(1e-80, min(value)), min(max(value), 1e5))
self._x_data.value = value
if len(self.x_data) == len(self.y_data):
self._update_data()
@property
def y_data(self):
......@@ -54,13 +50,19 @@ class PlotGeneral:
@y_data.setter
def y_data(self, value):
self._ax_semilogy.lines[0].set_xdata(value)
self._ax_semilogy.set_xlim(
max(1e-80, min(value)), min(max(value), 1e5))
self._ax_complex.lines[0].set_xdata(value)
self._ax_complex.set_xlim(
max(1e-80, min(value)), min(max(value), 1e5))
self._y_data.value = value
if len(self.x_data) == len(self.y_data):
self._update_data()
def _update_data(self) -> None:
self._ax_complex.lines[0].set_data(self.x_data, self.y_data)
self._ax_semilogy.lines[0].set_data(self.x_data, self.y_data)
self._ax_complex.relim()
self._ax_semilogy.relim()
self._ax_complex.autoscale_view()
self._ax_semilogy.autoscale_view()
self._fig_semilogy.canvas.draw()
self._fig_complex.canvas.draw()
@property
def x_label(self) -> str:
......
......@@ -117,3 +117,35 @@ class PlotVarious(PlotGeneral):
self.y_label = "imaginary part of M_n"
self.figshow(self._fig_semilogy)
def plot_dummy(self, real=True, twoD_plot=True, res=None) -> None:
"""
function for testing purposes
"""
if res is not None:
self.res = res
self.title = "The first {} coefficients of dummy".format(self.res)
_ = np.linspace(0, self.res - 1, self.res)
def dummy(n):
out = 10 * (np.sin(n) + 2 + 1j * (np.cos(n) + 2))
return out
if twoD_plot:
self.x_data = [dummy(int(n)).real for n in _]
self.x_label = "real part of dummy"
self.y_data = [dummy(int(n)).imag for n in _]
self.y_label = "imaginary part of M_n"
self.figshow(self._fig_complex)
else:
self.x_data = _
self.x_label = "n"
if real:
self.y_data = [dummy(int(n)).real for n in _]
self.y_label = "real part of M_n"
else:
self.y_data = [dummy(int(n)).imag for n in _]
self.y_label = "imaginary part of M_n"
self.figshow(self._fig_semilogy)
......@@ -56,4 +56,5 @@ class TestPlotVarious(BaseTestComposite):
self.cls.R_0 = self.R0
def test_plot_various(self) -> None:
PlotAcoustofluidics(baseclass=self.cls)
a = PlotAcoustofluidics(baseclass=self.cls)
a.plot_dummy(real=False, twoD_plot=False)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment