Skip to content

Commit 6edca4d

Browse files
committed
Remove deprecated plot alias; update tests
1 parent ab817a9 commit 6edca4d

4 files changed

Lines changed: 30 additions & 32 deletions

File tree

src/easydiffraction/display/plotters/base.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -115,27 +115,3 @@ def plot_single_crystal(
115115
height: Backend-specific height (text rows or pixels).
116116
"""
117117
pass
118-
119-
def plot(
120-
self,
121-
x,
122-
y_series,
123-
labels,
124-
axes_labels,
125-
title,
126-
height,
127-
):
128-
"""Render a pattern plot (backward-compatible alias).
129-
130-
.. deprecated::
131-
Use :meth:`plot_powder` instead.
132-
133-
Args:
134-
x: 1D array of x-axis values.
135-
y_series: Sequence of y arrays to plot.
136-
labels: Identifiers corresponding to y_series.
137-
axes_labels: Pair of strings for the x and y titles.
138-
title: Figure title.
139-
height: Backend-specific height (text rows or pixels).
140-
"""
141-
return self.plot_powder(x, y_series, labels, axes_labels, title, height)

src/easydiffraction/display/plotters/plotly.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ class PlotlyPlotter(PlotterBase):
3636
if in_pycharm():
3737
pio.renderers.default = 'browser'
3838

39-
def _get_powder_trace(self, x, y, label):
39+
def _get_powder_trace(
40+
self,
41+
x,
42+
y,
43+
label,
44+
):
4045
"""Create a Plotly trace for powder diffraction data.
4146
4247
Args:
@@ -63,7 +68,12 @@ def _get_powder_trace(self, x, y, label):
6368

6469
return trace
6570

66-
def _get_single_crystal_trace(self, x_calc, y_meas, y_meas_su):
71+
def _get_single_crystal_trace(
72+
self,
73+
x_calc,
74+
y_meas,
75+
y_meas_su,
76+
):
6777
"""Create a Plotly trace for single crystal diffraction data.
6878
6979
Args:
@@ -133,7 +143,11 @@ def _get_config(self):
133143
],
134144
)
135145

136-
def _get_figure(self, data, layout):
146+
def _get_figure(
147+
self,
148+
data,
149+
layout,
150+
):
137151
"""Create and configure a Plotly figure.
138152
139153
Args:
@@ -150,7 +164,10 @@ def _get_figure(self, data, layout):
150164
fig.update_yaxes(tickformat=',.6~g', separatethousands=True)
151165
return fig
152166

153-
def _show_figure(self, fig):
167+
def _show_figure(
168+
self,
169+
fig,
170+
):
154171
"""Display a Plotly figure.
155172
156173
Renders the figure using the appropriate method for the current
@@ -172,7 +189,12 @@ def _show_figure(self, fig):
172189
)
173190
display(HTML(html_fig))
174191

175-
def _get_layout(self, title, axes_labels, **kwargs):
192+
def _get_layout(
193+
self,
194+
title,
195+
axes_labels,
196+
**kwargs,
197+
):
176198
"""Create a Plotly layout configuration.
177199
178200
Args:

tests/unit/easydiffraction/display/plotters/test_ascii.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test_ascii_plotter_plot_minimal(capsys):
1818
x = np.array([0.0, 1.0, 2.0])
1919
y = np.array([1.0, 2.0, 3.0])
2020
p = AsciiPlotter()
21-
p.plot(x=x, y_series=[y], labels=['meas'], axes_labels=['x', 'y'], title='T', height=5)
21+
p.plot_powder(x=x, y_series=[y], labels=['meas'], axes_labels=['x', 'y'], title='T', height=5)
2222
out = capsys.readouterr().out
2323
assert 'Displaying data for selected x-range' in out
2424

tests/unit/easydiffraction/display/plotters/test_plotly.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ def __init__(self, html):
7373
assert hasattr(trace, 'kwargs')
7474
assert trace.kwargs['x'] == x and trace.kwargs['y'] == y
7575

76-
# Exercise plot (non-PyCharm, display path)
77-
plotter.plot(
76+
# Exercise plot_powder (non-PyCharm, display path)
77+
plotter.plot_powder(
7878
x,
7979
y_series=[y],
8080
labels=['calc'],

0 commit comments

Comments
 (0)