Skip to content

Commit 0c7b234

Browse files
igerberclaude
andcommitted
Fix doc snippet test failures: use self-contained examples for synth/dose-response
Replace SyntheticDiD and ContinuousDiD fit examples (which require specific data formats) with self-contained dict/DataFrame examples. Add plotly backend block to context-dependent snippets list. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 58a552c commit 0c7b234

2 files changed

Lines changed: 20 additions & 19 deletions

File tree

docs/api/visualization.rst

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,15 @@ Example
102102

103103
.. code-block:: python
104104
105-
from diff_diff import SyntheticDiD, plot_synth_weights
105+
from diff_diff import plot_synth_weights
106106
107-
sdid = SyntheticDiD()
108-
results = sdid.fit(data, outcome='y', unit='unit_id',
109-
time='period', treatment='treated')
107+
# Plot from a weights dictionary
108+
weights = {"unit_A": 0.40, "unit_B": 0.30, "unit_C": 0.20, "unit_D": 0.10}
109+
ax = plot_synth_weights(weights=weights)
110110
111-
# Bar chart of unit weights
112-
ax = plot_synth_weights(results)
113-
114-
# Show time weights instead
115-
ax = plot_synth_weights(results, weight_type='time')
111+
# Or from SyntheticDiD results:
112+
# ax = plot_synth_weights(results)
113+
# ax = plot_synth_weights(results, weight_type='time')
116114
117115
plot_staircase
118116
--------------
@@ -151,18 +149,20 @@ Example
151149

152150
.. code-block:: python
153151
154-
from diff_diff import ContinuousDiD, plot_dose_response
155-
156-
cdid = ContinuousDiD()
157-
results = cdid.fit(data, outcome='y', unit='unit_id',
158-
time='period', first_treat='first_treat',
159-
dose='dose')
152+
import pandas as pd
153+
from diff_diff import plot_dose_response
160154
161-
# ATT dose-response curve
162-
ax = plot_dose_response(results, target='att')
155+
# Plot from a DataFrame with dose-response data
156+
dr_data = pd.DataFrame({
157+
'dose': [1, 2, 3, 4, 5],
158+
'effect': [0.1, 0.3, 0.5, 0.4, 0.3],
159+
'se': [0.05, 0.06, 0.07, 0.08, 0.09],
160+
})
161+
ax = plot_dose_response(data=dr_data)
163162
164-
# ACRT dose-response curve
165-
ax = plot_dose_response(results, target='acrt')
163+
# Or from ContinuousDiD results:
164+
# ax = plot_dose_response(results, target='att')
165+
# ax = plot_dose_response(results, target='acrt')
166166
167167
plot_group_time_heatmap
168168
-----------------------

tests/test_doc_snippets.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ def _restore_datasets_module():
357357
"api_bacon:block2",
358358
"api_visualization:block2",
359359
"api_visualization:block3",
360+
"api_visualization:block8",
360361
"python_comparison:block5",
361362
"quickstart:block3",
362363
"quickstart:block9",

0 commit comments

Comments
 (0)