Skip to content

Commit 4cf362c

Browse files
committed
test: add python fixtures support for stats/incr/wmean
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: passed - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent d4045a4 commit 4cf362c

3 files changed

Lines changed: 363 additions & 28 deletions

File tree

Lines changed: 302 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,302 @@
1+
[
2+
{
3+
"step": 1,
4+
"x": 3.0471707975443136,
5+
"w": 3.9559294497604784,
6+
"mean": 3.0471707975443136
7+
},
8+
{
9+
"step": 2,
10+
"x": -10.399841062404956,
11+
"w": 3.3577691973009576,
12+
"mean": -3.126444550583255
13+
},
14+
{
15+
"step": 3,
16+
"x": 7.5045119580645725,
17+
"w": 3.555310355269042,
18+
"mean": 0.3509975744077484
19+
},
20+
{
21+
"step": 4,
22+
"x": 9.405647163912139,
23+
"w": 3.925572252007643,
24+
"mean": 2.753544869877046
25+
},
26+
{
27+
"step": 5,
28+
"x": -19.510351886538363,
29+
"w": 2.348687300137866,
30+
"mean": -0.2966862687887889
31+
},
32+
{
33+
"step": 6,
34+
"x": -13.021795068623181,
35+
"w": 2.88683186016918,
36+
"mean": -2.1306885327326004
37+
},
38+
{
39+
"step": 7,
40+
"x": 1.2784040316728538,
41+
"w": 0.7850052908255215,
42+
"mean": -2.0021205716643617
43+
},
44+
{
45+
"step": 8,
46+
"x": -3.162425923435822,
47+
"w": 0.6611973603262699,
48+
"mean": -2.0378432392675006
49+
},
50+
{
51+
"step": 9,
52+
"x": -0.16801157504288794,
53+
"w": 3.3751745127733113,
54+
"mean": -1.7838942273298977
55+
},
56+
{
57+
"step": 10,
58+
"x": -8.5304392757358,
59+
"w": 2.4083714101013496,
60+
"mean": -2.379942511320534
61+
},
62+
{
63+
"step": 11,
64+
"x": 8.793979748628285,
65+
"w": 2.8696569217578256,
66+
"mean": -1.3156926211374218
67+
},
68+
{
69+
"step": 12,
70+
"x": 7.777919354289483,
71+
"w": 3.8484944013385256,
72+
"mean": -0.28571103145409305
73+
},
74+
{
75+
"step": 13,
76+
"x": 0.6603069756121605,
77+
"w": 3.2101197680028952,
78+
"mean": -0.2040497079223875
79+
},
80+
{
81+
"step": 14,
82+
"x": 11.272412069680328,
83+
"w": 2.81253906322418,
84+
"mean": 0.6028869213396181
85+
},
86+
{
87+
"step": 15,
88+
"x": 4.675093422520456,
89+
"w": 2.8401150876525265,
90+
"mean": 0.872852516773853
91+
},
92+
{
93+
"step": 16,
94+
"x": -8.592924628832382,
95+
"w": 1.5893554805068,
96+
"mean": 0.5342425491363226
97+
},
98+
{
99+
"step": 17,
100+
"x": 3.6875078408249884,
101+
"w": 0.2510073893829031,
102+
"mean": 0.5519568003899903
103+
},
104+
{
105+
"step": 18,
106+
"x": -9.588826008289988,
107+
"w": 2.239915207238576,
108+
"mean": 0.0678565402877354
109+
},
110+
{
111+
"step": 19,
112+
"x": 8.784503013072726,
113+
"w": 1.1514648968156933,
114+
"mean": 0.2766434525404932
115+
},
116+
{
117+
"step": 20,
118+
"x": -0.49925910986252897,
119+
"w": 2.1017903542507175,
120+
"mean": 0.2441410703285499
121+
},
122+
{
123+
"step": 21,
124+
"x": -1.8486236354526056,
125+
"w": 4.281675059014014,
126+
"mean": 0.07959462355871812
127+
},
128+
{
129+
"step": 22,
130+
"x": -6.809295444039414,
131+
"w": 1.2463034807401698,
132+
"mean": -0.07453994202242903
133+
},
134+
{
135+
"step": 23,
136+
"x": 12.225413386740303,
137+
"w": 0.3856834342764235,
138+
"mean": 0.010039483490497911
139+
},
140+
{
141+
"step": 24,
142+
"x": -1.5452948206880215,
143+
"w": 1.4787810709077833,
144+
"mean": -0.029914116527385744
145+
},
146+
{
147+
"step": 25,
148+
"x": -4.283278221631072,
149+
"w": 1.5386094130567498,
150+
"mean": -0.14063615675192645
151+
},
152+
{
153+
"step": 26,
154+
"x": -3.5213355048822956,
155+
"w": 3.343390922161786,
156+
"mean": -0.32163256326353584
157+
},
158+
{
159+
"step": 27,
160+
"x": 5.323091855533487,
161+
"w": 2.829457546472264,
162+
"mean": -0.07696426621497057
163+
},
164+
{
165+
"step": 28,
166+
"x": 3.6544406436407835,
167+
"w": 3.9411012246214265,
168+
"mean": 0.13548865366219276
169+
},
170+
{
171+
"step": 29,
172+
"x": 4.1273261159598835,
173+
"w": 3.355136347604199,
174+
"mean": 0.3200323834598058
175+
},
176+
{
177+
"step": 30,
178+
"x": 4.308210030078827,
179+
"w": 2.0912956210563456,
180+
"mean": 0.4317363357791127
181+
},
182+
{
183+
"step": 31,
184+
"x": 21.416476008704613,
185+
"w": 4.08869988486357,
186+
"mean": 1.5212025421425204
187+
},
188+
{
189+
"step": 32,
190+
"x": -4.064150163846156,
191+
"w": 0.9181673075477492,
192+
"mean": 1.4568355240616275
193+
},
194+
{
195+
"step": 33,
196+
"x": -5.122427290715374,
197+
"w": 0.21128915835591636,
198+
"mean": 1.4394336829268486
199+
},
200+
{
201+
"step": 34,
202+
"x": -8.137727282478778,
203+
"w": 0.5412345178006446,
204+
"mean": 1.3749825600895866
205+
},
206+
{
207+
"step": 35,
208+
"x": 6.159794225754957,
209+
"w": 3.639560817922607,
210+
"mean": 1.582139838161509
211+
},
212+
{
213+
"step": 36,
214+
"x": 11.289722927208917,
215+
"w": 2.3631984282317986,
216+
"mean": 1.8475743480392357
217+
},
218+
{
219+
"step": 37,
220+
"x": -1.1394745765487508,
221+
"w": 0.8902317172646488,
222+
"mean": 1.8171205821224452
223+
},
224+
{
225+
"step": 38,
226+
"x": -8.401564769625281,
227+
"w": 2.5551193980064815,
228+
"mean": 1.5266007308371616
229+
},
230+
{
231+
"step": 39,
232+
"x": -8.244812156912396,
233+
"w": 0.8463293032945253,
234+
"mean": 1.435442529141028
235+
},
236+
{
237+
"step": 40,
238+
"x": 6.505927878247011,
239+
"w": 3.511969837880907,
240+
"mean": 1.6244173800465052
241+
},
242+
{
243+
"step": 41,
244+
"x": 7.432541712034423,
245+
"w": 2.2861657503127506,
246+
"mean": 1.761991460740914
247+
},
248+
{
249+
"step": 42,
250+
"x": 5.4315426830519495,
251+
"w": 1.9670040078727644,
252+
"mean": 1.8352822469844088
253+
},
254+
{
255+
"step": 43,
256+
"x": -6.655097072886943,
257+
"w": 1.577409236824595,
258+
"mean": 1.7014373651904717
259+
},
260+
{
261+
"step": 44,
262+
"x": 2.3216132306671975,
263+
"w": 3.188384706282554,
264+
"mean": 1.7205884505077298
265+
},
266+
{
267+
"step": 45,
268+
"x": 1.1668580914072821,
269+
"w": 1.8728817917116134,
270+
"mean": 1.7107231718926006
271+
},
272+
{
273+
"step": 46,
274+
"x": 2.1868859672901295,
275+
"w": 0.5294846046488949,
276+
"mean": 1.7131094853391238
277+
},
278+
{
279+
"step": 47,
280+
"x": 8.714287779481898,
281+
"w": 0.6782289203905251,
282+
"mean": 1.7577662372038756
283+
},
284+
{
285+
"step": 48,
286+
"x": 2.2359554877468226,
287+
"w": 4.813298556292621,
288+
"mean": 1.7784750415795718
289+
},
290+
{
291+
"step": 49,
292+
"x": 6.789135630718949,
293+
"w": 4.552045384467275,
294+
"mean": 1.9756181293054198
295+
},
296+
{
297+
"step": 50,
298+
"x": 0.6757906948889146,
299+
"w": 3.5285649556726733,
300+
"mean": 1.9371486375865798
301+
}
302+
]
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env python
2+
#
3+
# @license Apache-2.0
4+
#
5+
# Copyright (c) 2026 The Stdlib Authors.
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
19+
"""Generate fixture data for testing incremental weighted mean."""
20+
21+
import json
22+
import numpy as np
23+
24+
rng = np.random.default_rng(42)
25+
26+
n = 50
27+
28+
x = rng.normal(loc=0.0, scale=10.0, size=n)
29+
w = rng.uniform(0.1, 5.0, size=n)
30+
31+
records = []
32+
33+
for k in range(1, n + 1):
34+
xk = x[:k]
35+
wk = w[:k]
36+
37+
mu = np.average(xk, weights=wk)
38+
39+
records.append({
40+
"step": k,
41+
"x": float(x[k - 1]),
42+
"w": float(w[k - 1]),
43+
"mean": float(mu)
44+
})
45+
46+
with open("data.json", "w", encoding="utf-8") as f:
47+
json.dump(records, f, indent=2)
48+
49+
print("data.json written with", n, "records")

0 commit comments

Comments
 (0)