Skip to content

Commit 20ae157

Browse files
jayzhou2309claude
andcommitted
Add failing test for overall trendline on marginal subplots
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 9447f1c commit 20ae157

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

‎tests/test_optional/test_px/test_trendline.py‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,34 @@ def test_overall_trendline(backend):
264264
params3 = results3["px_fit_results"].iloc[0].params
265265

266266
assert np.all(np.array_equal(params1, params3))
267+
268+
269+
@pytest.mark.parametrize(
270+
"kwargs",
271+
[
272+
dict(marginal_x="box", marginal_y="box"),
273+
dict(marginal_x="histogram", facet_col="smoker"),
274+
dict(marginal_y="violin", facet_row="smoker"),
275+
],
276+
)
277+
def test_overall_trendline_skips_marginals(backend, kwargs):
278+
df = px.data.tips(return_type=backend)
279+
fig = px.scatter(
280+
df,
281+
x="total_bill",
282+
y="tip",
283+
color="sex",
284+
trendline="ols",
285+
trendline_scope="overall",
286+
**kwargs,
287+
)
288+
trendline_axes = [
289+
(t.xaxis, t.yaxis) for t in fig.data if t.name == "Overall Trendline"
290+
]
291+
scatter_axes = {
292+
(t.xaxis, t.yaxis)
293+
for t in fig.data
294+
if t.type == "scatter" and t.name != "Overall Trendline"
295+
}
296+
assert len(trendline_axes) == len(scatter_axes)
297+
assert set(trendline_axes) == scatter_axes

0 commit comments

Comments
 (0)