Skip to content

Commit 0ef224b

Browse files
igerberclaude
andcommitted
Fix quickstart post_periods and catch ImportError in doc snippet tests
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1fc290e commit 0ef224b

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

docs/quickstart.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ Examine treatment effects over time:
131131
outcome='outcome',
132132
treatment='treated',
133133
time='period',
134-
post_periods=[5, 6, 7],
134+
post_periods=[5, 6, 7, 8, 9],
135135
reference_period=4
136136
)
137137

tests/test_doc_snippets.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def _build_namespace() -> dict:
161161
# Synthetic datasets that doc snippets commonly reference
162162
rng = np.random.default_rng(42)
163163
staggered = diff_diff.generate_staggered_data(
164-
n_units=60, n_periods=8, seed=42
164+
n_units=60, n_periods=10, seed=42
165165
)
166166
# Add alias columns that doc snippets expect
167167
# Use a simple time split (not unit-specific) so basic 2x2 DID works
@@ -354,9 +354,10 @@ def test_doc_snippet(test_id: str, code: str, skip_reason: Optional[str]):
354354
# context block (e.g. ``results`` from an earlier fit). This is
355355
# expected for isolated execution — not an API mismatch.
356356
pass
357-
except ModuleNotFoundError:
358-
# Comparison pages import third-party packages (pyfixest,
359-
# linearmodels, differences) that are not installed.
357+
except ImportError:
358+
# ImportError covers both ModuleNotFoundError (comparison pages
359+
# importing pyfixest, linearmodels, etc.) and optional-dependency
360+
# guards (e.g. matplotlib required for plotting functions).
360361
pass
361362
except Exception as exc:
362363
pytest.fail(

0 commit comments

Comments
 (0)