Skip to content

Commit 3e49287

Browse files
committed
Add snapshot tests for notebook outputs
Introduces snapshot-based tests using Syrupy to verify computational outputs from tutorial notebooks. Updates pyproject.toml to include Syrupy as a dev dependency. Adds test_notebook_snapshots.py and corresponding snapshot data to ensure codebase changes do not alter expected analysis results.
1 parent 7a34a81 commit 3e49287

File tree

3 files changed

+1149
-0
lines changed

3 files changed

+1149
-0
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ dependencies = [
5050
dev = [
5151
"pytest>=8.0",
5252
"pytest-cov>=4.1",
53+
"syrupy>=4.0",
5354
"nitime",
5455
"black>=24.0",
5556
"ruff>=0.8.0",
Lines changed: 342 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,342 @@
1+
# serializer version: 1
2+
# name: test_baccala_example2_directed_transfer_function[dtf_at_25hz]
3+
list([
4+
list([
5+
0.7098937741510488,
6+
0.04170307980738457,
7+
0.24840314604156621,
8+
]),
9+
list([
10+
0.19990826425127378,
11+
0.4529154194325527,
12+
0.34717631631617346,
13+
]),
14+
list([
15+
0.057228935759376855,
16+
0.1397690125410971,
17+
0.8030020516995261,
18+
]),
19+
])
20+
# ---
21+
# name: test_baccala_example2_directed_transfer_function[dtf_shape]
22+
tuple(
23+
1,
24+
500,
25+
3,
26+
3,
27+
)
28+
# ---
29+
# name: test_baccala_example2_partial_directed_coherence[pdc_at_25hz]
30+
list([
31+
list([
32+
0.695584667715585,
33+
0.10932855637329505,
34+
0.07902806469911004,
35+
]),
36+
list([
37+
0.3043583373045675,
38+
0.7941124097945432,
39+
0.4179724448625634,
40+
]),
41+
list([
42+
5.699497984730916e-05,
43+
0.09655903383216162,
44+
0.5029994904383266,
45+
]),
46+
])
47+
# ---
48+
# name: test_baccala_example2_partial_directed_coherence[pdc_shape]
49+
tuple(
50+
1,
51+
500,
52+
3,
53+
3,
54+
)
55+
# ---
56+
# name: test_dhamala_example1_direct_dtf[ddtf_at_30hz]
57+
list([
58+
list([
59+
0.029642439730251016,
60+
0.0004439107406330511,
61+
0.009674579344505102,
62+
]),
63+
list([
64+
2.9065855469685593e-05,
65+
0.017084639325064658,
66+
9.668097595418112e-06,
67+
]),
68+
list([
69+
7.296534873537972e-05,
70+
0.012195537594898111,
71+
0.01780881060173541,
72+
]),
73+
])
74+
# ---
75+
# name: test_dhamala_example1_direct_dtf[ddtf_shape]
76+
tuple(
77+
1,
78+
2000,
79+
3,
80+
3,
81+
)
82+
# ---
83+
# name: test_dhamala_example1_subset_granger[subset_gc_pair0to1_at_30hz]
84+
0.6382974682992835
85+
# ---
86+
# name: test_dhamala_example1_subset_granger[subset_gc_shape]
87+
tuple(
88+
1,
89+
2000,
90+
3,
91+
3,
92+
)
93+
# ---
94+
# name: test_ding_example1_generalized_pdc[gpdc_at_50hz]
95+
list([
96+
list([
97+
0.9303429300290544,
98+
0.0002665085007102023,
99+
]),
100+
list([
101+
0.06965706997094563,
102+
0.9997334914992897,
103+
]),
104+
])
105+
# ---
106+
# name: test_ding_example1_generalized_pdc[gpdc_shape]
107+
tuple(
108+
1,
109+
500,
110+
2,
111+
2,
112+
)
113+
# ---
114+
# name: test_ding_example1_granger_causality[granger_shape]
115+
tuple(
116+
1,
117+
500,
118+
2,
119+
2,
120+
)
121+
# ---
122+
# name: test_ding_example1_granger_causality[granger_x1_to_x2_at_50hz]
123+
0.05835666385356131
124+
# ---
125+
# name: test_ding_example1_granger_causality[granger_x2_to_x1_at_50hz]
126+
0.00020339332917718167
127+
# ---
128+
# name: test_intro_basic_coherence[coherence_at_200hz]
129+
0.9809957145809289
130+
# ---
131+
# name: test_intro_basic_coherence[coherence_shape]
132+
tuple(
133+
30013,
134+
2,
135+
2,
136+
)
137+
# ---
138+
# name: test_intro_basic_power_spectrum[power_at_200hz]
139+
list([
140+
1.5810365370744819,
141+
1.650108418360882,
142+
])
143+
# ---
144+
# name: test_intro_basic_power_spectrum[power_shape]
145+
tuple(
146+
30013,
147+
2,
148+
)
149+
# ---
150+
# name: test_intro_canonical_coherence[canonical_coherence_at_50hz]
151+
1.0000000000000013
152+
# ---
153+
# name: test_intro_canonical_coherence[canonical_coherence_labels]
154+
list([
155+
0,
156+
1,
157+
])
158+
# ---
159+
# name: test_intro_canonical_coherence[canonical_coherence_shape]
160+
tuple(
161+
1,
162+
500,
163+
2,
164+
2,
165+
)
166+
# ---
167+
# name: test_intro_coherence_phase[phase_at_200hz]
168+
1.6138623399664196
169+
# ---
170+
# name: test_intro_coherence_phase[phase_shape]
171+
tuple(
172+
30013,
173+
2,
174+
2,
175+
)
176+
# ---
177+
# name: test_intro_coherence_with_time_windows[coherence_time_shape]
178+
tuple(
179+
30,
180+
1000,
181+
2,
182+
2,
183+
)
184+
# ---
185+
# name: test_intro_coherence_with_time_windows[frequency_resolution]
186+
5.0
187+
# ---
188+
# name: test_intro_coherency[coherency_magnitude_at_200hz]
189+
0.9904522777907722
190+
# ---
191+
# name: test_intro_coherency[coherency_phase_at_200hz]
192+
-1.6138623399664196
193+
# ---
194+
# name: test_intro_coherency[coherency_shape]
195+
tuple(
196+
30013,
197+
2,
198+
2,
199+
)
200+
# ---
201+
# name: test_intro_debiased_squared_phase_lag_index[debiased_pli2_at_200hz]
202+
0.0
203+
# ---
204+
# name: test_intro_debiased_squared_phase_lag_index[debiased_pli2_shape]
205+
tuple(
206+
1,
207+
30013,
208+
2,
209+
2,
210+
)
211+
# ---
212+
# name: test_intro_debiased_squared_weighted_phase_lag_index[dwpli2_at_200hz]
213+
0.995062950359831
214+
# ---
215+
# name: test_intro_debiased_squared_weighted_phase_lag_index[dwpli2_shape]
216+
tuple(
217+
1,
218+
30013,
219+
2,
220+
2,
221+
)
222+
# ---
223+
# name: test_intro_delay[delay_mean]
224+
nan
225+
# ---
226+
# name: test_intro_delay[delay_shape]
227+
tuple(
228+
12005,
229+
7,
230+
2,
231+
2,
232+
)
233+
# ---
234+
# name: test_intro_global_coherence[global_coherence_components_shape]
235+
tuple(
236+
1,
237+
1000,
238+
4,
239+
1,
240+
)
241+
# ---
242+
# name: test_intro_global_coherence[global_coherence_mean]
243+
0.002472688733431512
244+
# ---
245+
# name: test_intro_global_coherence[global_coherence_shape]
246+
tuple(
247+
1,
248+
1000,
249+
1,
250+
)
251+
# ---
252+
# name: test_intro_group_delay[group_delay_mean]
253+
nan
254+
# ---
255+
# name: test_intro_group_delay[group_delay_r_value_shape]
256+
tuple(
257+
2,
258+
2,
259+
)
260+
# ---
261+
# name: test_intro_group_delay[group_delay_shape]
262+
tuple(
263+
2,
264+
2,
265+
)
266+
# ---
267+
# name: test_intro_group_delay[group_delay_slope_shape]
268+
tuple(
269+
2,
270+
2,
271+
)
272+
# ---
273+
# name: test_intro_imaginary_coherence[imag_coherence_at_200hz]
274+
0.9895339329869453
275+
# ---
276+
# name: test_intro_imaginary_coherence[imag_coherence_shape]
277+
tuple(
278+
30013,
279+
2,
280+
2,
281+
)
282+
# ---
283+
# name: test_intro_multitaper_connectivity_wrapper[coordinate_names]
284+
list([
285+
'time',
286+
'frequency',
287+
'source',
288+
'target',
289+
])
290+
# ---
291+
# name: test_intro_multitaper_connectivity_wrapper[output_dimensions]
292+
list([
293+
'time',
294+
'frequency',
295+
'source',
296+
'target',
297+
])
298+
# ---
299+
# name: test_intro_multitaper_connectivity_wrapper[output_type]
300+
'DataArray'
301+
# ---
302+
# name: test_intro_pairwise_phase_consistency[ppc_at_200hz]
303+
0.16570573296183747
304+
# ---
305+
# name: test_intro_pairwise_phase_consistency[ppc_shape]
306+
tuple(
307+
1,
308+
30013,
309+
2,
310+
2,
311+
)
312+
# ---
313+
# name: test_intro_phase_locking_value[plv_at_200hz]
314+
0.5083356135134324
315+
# ---
316+
# name: test_intro_phase_locking_value[plv_shape]
317+
tuple(
318+
1,
319+
30013,
320+
2,
321+
2,
322+
)
323+
# ---
324+
# name: test_intro_phase_slope_index[psi_mean]
325+
nan
326+
# ---
327+
# name: test_intro_phase_slope_index[psi_shape]
328+
tuple(
329+
2,
330+
2,
331+
)
332+
# ---
333+
# name: test_intro_weighted_phase_lag_index[wpli_at_200hz]
334+
-0.9982088764555365
335+
# ---
336+
# name: test_intro_weighted_phase_lag_index[wpli_shape]
337+
tuple(
338+
30013,
339+
2,
340+
2,
341+
)
342+
# ---

0 commit comments

Comments
 (0)