scitex 2.15.1__py3-none-any.whl → 2.15.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- scitex/__init__.py +68 -61
- scitex/_mcp_tools/introspect.py +42 -23
- scitex/_mcp_tools/template.py +24 -0
- scitex/ai/classification/timeseries/_TimeSeriesSlidingWindowSplit.py +30 -1550
- scitex/ai/classification/timeseries/_sliding_window_core.py +467 -0
- scitex/ai/classification/timeseries/_sliding_window_plotting.py +369 -0
- scitex/audio/__init__.py +2 -2
- scitex/audio/_tts.py +18 -10
- scitex/audio/engines/base.py +17 -10
- scitex/audio/engines/elevenlabs_engine.py +1 -1
- scitex/canvas/editor/flask_editor/_core/__init__.py +27 -0
- scitex/canvas/editor/flask_editor/_core/_bbox_extraction.py +200 -0
- scitex/canvas/editor/flask_editor/_core/_editor.py +173 -0
- scitex/canvas/editor/flask_editor/_core/_export_helpers.py +353 -0
- scitex/canvas/editor/flask_editor/_core/_routes_basic.py +190 -0
- scitex/canvas/editor/flask_editor/_core/_routes_export.py +332 -0
- scitex/canvas/editor/flask_editor/_core/_routes_panels.py +252 -0
- scitex/canvas/editor/flask_editor/_core/_routes_save.py +218 -0
- scitex/canvas/editor/flask_editor/_core.py +25 -1684
- scitex/cli/introspect.py +112 -74
- scitex/cli/main.py +2 -0
- scitex/cli/plt.py +357 -0
- scitex/cli/repro.py +15 -8
- scitex/cli/resource.py +15 -8
- scitex/cli/scholar/__init__.py +15 -8
- scitex/cli/social.py +6 -6
- scitex/cli/stats.py +15 -8
- scitex/cli/template.py +129 -12
- scitex/cli/tex.py +15 -8
- scitex/cli/writer.py +15 -8
- scitex/cloud/__init__.py +41 -2
- scitex/config/_env_registry.py +84 -19
- scitex/context/__init__.py +22 -0
- scitex/dev/__init__.py +20 -1
- scitex/gen/__init__.py +50 -14
- scitex/gen/_list_packages.py +4 -4
- scitex/introspect/__init__.py +16 -9
- scitex/introspect/_core.py +7 -8
- scitex/{gen/_inspect_module.py → introspect/_list_api.py} +43 -54
- scitex/introspect/_mcp/__init__.py +10 -6
- scitex/introspect/_mcp/handlers.py +37 -12
- scitex/introspect/_members.py +7 -3
- scitex/introspect/_signature.py +3 -3
- scitex/introspect/_source.py +2 -2
- scitex/io/_save.py +1 -2
- scitex/logging/_formatters.py +19 -9
- scitex/mcp_server.py +1 -1
- scitex/os/__init__.py +4 -0
- scitex/{gen → os}/_check_host.py +4 -5
- scitex/plt/__init__.py +11 -14
- scitex/session/__init__.py +26 -7
- scitex/session/_decorator.py +1 -1
- scitex/sh/__init__.py +7 -4
- scitex/social/__init__.py +10 -8
- scitex/stats/_mcp/_handlers/__init__.py +31 -0
- scitex/stats/_mcp/_handlers/_corrections.py +113 -0
- scitex/stats/_mcp/_handlers/_descriptive.py +78 -0
- scitex/stats/_mcp/_handlers/_effect_size.py +106 -0
- scitex/stats/_mcp/_handlers/_format.py +94 -0
- scitex/stats/_mcp/_handlers/_normality.py +110 -0
- scitex/stats/_mcp/_handlers/_posthoc.py +224 -0
- scitex/stats/_mcp/_handlers/_power.py +247 -0
- scitex/stats/_mcp/_handlers/_recommend.py +102 -0
- scitex/stats/_mcp/_handlers/_run_test.py +279 -0
- scitex/stats/_mcp/_handlers/_stars.py +48 -0
- scitex/stats/_mcp/handlers.py +19 -1171
- scitex/stats/auto/_stat_style.py +175 -0
- scitex/stats/auto/_style_definitions.py +411 -0
- scitex/stats/auto/_styles.py +22 -620
- scitex/stats/descriptive/__init__.py +11 -8
- scitex/stats/descriptive/_ci.py +39 -0
- scitex/stats/power/_power.py +15 -4
- scitex/str/__init__.py +2 -1
- scitex/str/_title_case.py +63 -0
- scitex/template/__init__.py +25 -10
- scitex/template/_code_templates.py +147 -0
- scitex/template/_mcp/handlers.py +81 -0
- scitex/template/_mcp/tool_schemas.py +55 -0
- scitex/template/_templates/__init__.py +51 -0
- scitex/template/_templates/audio.py +233 -0
- scitex/template/_templates/canvas.py +312 -0
- scitex/template/_templates/capture.py +268 -0
- scitex/template/_templates/config.py +43 -0
- scitex/template/_templates/diagram.py +294 -0
- scitex/template/_templates/io.py +107 -0
- scitex/template/_templates/module.py +53 -0
- scitex/template/_templates/plt.py +202 -0
- scitex/template/_templates/scholar.py +267 -0
- scitex/template/_templates/session.py +130 -0
- scitex/template/_templates/session_minimal.py +43 -0
- scitex/template/_templates/session_plot.py +67 -0
- scitex/template/_templates/session_stats.py +77 -0
- scitex/template/_templates/stats.py +323 -0
- scitex/template/_templates/writer.py +296 -0
- scitex/ui/_backends/_email.py +10 -2
- scitex/ui/_backends/_webhook.py +5 -1
- scitex/web/_search_pubmed.py +10 -6
- {scitex-2.15.1.dist-info → scitex-2.15.2.dist-info}/METADATA +1 -1
- {scitex-2.15.1.dist-info → scitex-2.15.2.dist-info}/RECORD +105 -64
- scitex/gen/_ci.py +0 -12
- scitex/gen/_title_case.py +0 -89
- /scitex/{gen → context}/_detect_environment.py +0 -0
- /scitex/{gen → context}/_get_notebook_path.py +0 -0
- /scitex/{gen/_shell.py → sh/_shell_legacy.py} +0 -0
- {scitex-2.15.1.dist-info → scitex-2.15.2.dist-info}/WHEEL +0 -0
- {scitex-2.15.1.dist-info → scitex-2.15.2.dist-info}/entry_points.txt +0 -0
- {scitex-2.15.1.dist-info → scitex-2.15.2.dist-info}/licenses/LICENSE +0 -0
scitex/stats/auto/_styles.py
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
# File: /home/ywatanabe/proj/scitex-code/src/scitex/stats/auto/_styles.py
|
|
2
|
+
# Timestamp: "2026-01-24 (ywatanabe)"
|
|
3
|
+
# File: /home/ywatanabe/proj/scitex-python/src/scitex/stats/auto/_styles.py
|
|
5
4
|
|
|
6
|
-
"""
|
|
7
|
-
Journal Style Presets - Publication-ready statistical formatting.
|
|
5
|
+
"""Journal Style Presets - Publication-ready statistical formatting.
|
|
8
6
|
|
|
9
7
|
This module defines formatting styles for major journal families:
|
|
10
8
|
- APA (American Psychological Association)
|
|
@@ -21,615 +19,21 @@ Each style specifies:
|
|
|
21
19
|
Supports both LaTeX and HTML output targets.
|
|
22
20
|
"""
|
|
23
21
|
|
|
24
|
-
from
|
|
25
|
-
|
|
26
|
-
from
|
|
27
|
-
from
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
# StatStyle
|
|
38
|
-
# =============================================================================
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
@dataclass
|
|
42
|
-
class StatStyle:
|
|
43
|
-
"""
|
|
44
|
-
Style configuration for statistical reporting.
|
|
45
|
-
|
|
46
|
-
Defines how to format statistical results for a specific journal
|
|
47
|
-
or output format.
|
|
48
|
-
|
|
49
|
-
Parameters
|
|
50
|
-
----------
|
|
51
|
-
id : str
|
|
52
|
-
Unique identifier for this style.
|
|
53
|
-
label : str
|
|
54
|
-
Human-readable label (e.g., "APA (LaTeX)").
|
|
55
|
-
target : OutputTarget
|
|
56
|
-
Output format: "latex", "html", or "plain".
|
|
57
|
-
stat_symbol_format : dict
|
|
58
|
-
Maps statistic symbols to their formatted versions.
|
|
59
|
-
Example: {"t": "\\mathit{t}", "p": "\\mathit{p}"}
|
|
60
|
-
p_format : str
|
|
61
|
-
Format string for p-values. Use {p:.3f} syntax.
|
|
62
|
-
alpha_thresholds : list of (float, str)
|
|
63
|
-
P-value thresholds for stars. Lower threshold = more stars.
|
|
64
|
-
Example: [(0.001, "***"), (0.01, "**"), (0.05, "*")]
|
|
65
|
-
effect_label_format : dict
|
|
66
|
-
Maps effect size names to their formatted labels.
|
|
67
|
-
n_format : str
|
|
68
|
-
Format string for sample sizes. Uses % formatting.
|
|
69
|
-
Example: "\\mathit{n}_{%s} = %d"
|
|
70
|
-
decimal_places_p : int
|
|
71
|
-
Decimal places for p-values.
|
|
72
|
-
decimal_places_stat : int
|
|
73
|
-
Decimal places for test statistics.
|
|
74
|
-
decimal_places_effect : int
|
|
75
|
-
Decimal places for effect sizes.
|
|
76
|
-
|
|
77
|
-
Examples
|
|
78
|
-
--------
|
|
79
|
-
>>> style = STAT_STYLES["apa_latex"]
|
|
80
|
-
>>> style.format_p(0.032)
|
|
81
|
-
'\\\\mathit{p} = 0.032'
|
|
82
|
-
>>> style.format_stat("t", 2.31, df=28)
|
|
83
|
-
'\\\\mathit{t}(28.0) = 2.31'
|
|
84
|
-
"""
|
|
85
|
-
|
|
86
|
-
id: str
|
|
87
|
-
label: str
|
|
88
|
-
target: OutputTarget
|
|
89
|
-
|
|
90
|
-
# Symbol formatting
|
|
91
|
-
stat_symbol_format: Dict[str, str] = field(default_factory=dict)
|
|
92
|
-
|
|
93
|
-
# P-value formatting
|
|
94
|
-
p_format: str = "p = {p:.3f}"
|
|
95
|
-
alpha_thresholds: List[Tuple[float, str]] = field(default_factory=list)
|
|
96
|
-
|
|
97
|
-
# Effect size labels
|
|
98
|
-
effect_label_format: Dict[str, str] = field(default_factory=dict)
|
|
99
|
-
|
|
100
|
-
# Sample size formatting
|
|
101
|
-
n_format: str = "n_{%s} = %d"
|
|
102
|
-
|
|
103
|
-
# Decimal places
|
|
104
|
-
decimal_places_p: int = 3
|
|
105
|
-
decimal_places_stat: int = 2
|
|
106
|
-
decimal_places_effect: int = 2
|
|
107
|
-
|
|
108
|
-
def format_stat(
|
|
109
|
-
self,
|
|
110
|
-
symbol: str,
|
|
111
|
-
value: float,
|
|
112
|
-
df: Optional[float] = None,
|
|
113
|
-
) -> str:
|
|
114
|
-
"""
|
|
115
|
-
Format a test statistic.
|
|
116
|
-
|
|
117
|
-
Parameters
|
|
118
|
-
----------
|
|
119
|
-
symbol : str
|
|
120
|
-
Statistic symbol (e.g., "t", "F", "chi2").
|
|
121
|
-
value : float
|
|
122
|
-
Statistic value.
|
|
123
|
-
df : float, optional
|
|
124
|
-
Degrees of freedom.
|
|
125
|
-
|
|
126
|
-
Returns
|
|
127
|
-
-------
|
|
128
|
-
str
|
|
129
|
-
Formatted statistic string.
|
|
130
|
-
"""
|
|
131
|
-
fmt_symbol = self.stat_symbol_format.get(symbol, symbol)
|
|
132
|
-
dp = self.decimal_places_stat
|
|
133
|
-
|
|
134
|
-
if df is not None:
|
|
135
|
-
return f"{fmt_symbol}({df:.1f}) = {value:.{dp}f}"
|
|
136
|
-
else:
|
|
137
|
-
return f"{fmt_symbol} = {value:.{dp}f}"
|
|
138
|
-
|
|
139
|
-
def format_p(self, p_value: float) -> str:
|
|
140
|
-
"""
|
|
141
|
-
Format a p-value.
|
|
142
|
-
|
|
143
|
-
Parameters
|
|
144
|
-
----------
|
|
145
|
-
p_value : float
|
|
146
|
-
P-value to format.
|
|
147
|
-
|
|
148
|
-
Returns
|
|
149
|
-
-------
|
|
150
|
-
str
|
|
151
|
-
Formatted p-value string.
|
|
152
|
-
"""
|
|
153
|
-
p_symbol = self.stat_symbol_format.get("p", "p")
|
|
154
|
-
dp = self.decimal_places_p
|
|
155
|
-
|
|
156
|
-
# Handle very small p-values
|
|
157
|
-
if p_value < 0.001:
|
|
158
|
-
return f"{p_symbol} < 0.001"
|
|
159
|
-
elif p_value < 0.0001:
|
|
160
|
-
return f"{p_symbol} < 0.0001"
|
|
161
|
-
else:
|
|
162
|
-
return f"{p_symbol} = {p_value:.{dp}f}"
|
|
163
|
-
|
|
164
|
-
def format_effect(self, name: str, value: float) -> str:
|
|
165
|
-
"""
|
|
166
|
-
Format an effect size.
|
|
167
|
-
|
|
168
|
-
Parameters
|
|
169
|
-
----------
|
|
170
|
-
name : str
|
|
171
|
-
Effect size name (e.g., "cohens_d_ind").
|
|
172
|
-
value : float
|
|
173
|
-
Effect size value.
|
|
174
|
-
|
|
175
|
-
Returns
|
|
176
|
-
-------
|
|
177
|
-
str
|
|
178
|
-
Formatted effect size string.
|
|
179
|
-
"""
|
|
180
|
-
label = self.effect_label_format.get(name, name)
|
|
181
|
-
dp = self.decimal_places_effect
|
|
182
|
-
return f"{label} = {value:.{dp}f}"
|
|
183
|
-
|
|
184
|
-
def format_n(self, group: str, n: int) -> str:
|
|
185
|
-
"""
|
|
186
|
-
Format a sample size.
|
|
187
|
-
|
|
188
|
-
Parameters
|
|
189
|
-
----------
|
|
190
|
-
group : str
|
|
191
|
-
Group name/label.
|
|
192
|
-
n : int
|
|
193
|
-
Sample size.
|
|
194
|
-
|
|
195
|
-
Returns
|
|
196
|
-
-------
|
|
197
|
-
str
|
|
198
|
-
Formatted sample size string.
|
|
199
|
-
"""
|
|
200
|
-
# Handle formats with and without group name placeholder
|
|
201
|
-
if "%s" in self.n_format:
|
|
202
|
-
return self.n_format % (group, n)
|
|
203
|
-
else:
|
|
204
|
-
# Format doesn't include group name, just use n
|
|
205
|
-
return self.n_format % n
|
|
206
|
-
|
|
207
|
-
def p_to_stars(self, p_value: float) -> str:
|
|
208
|
-
"""
|
|
209
|
-
Convert p-value to significance stars.
|
|
210
|
-
|
|
211
|
-
Parameters
|
|
212
|
-
----------
|
|
213
|
-
p_value : float
|
|
214
|
-
P-value.
|
|
215
|
-
|
|
216
|
-
Returns
|
|
217
|
-
-------
|
|
218
|
-
str
|
|
219
|
-
Stars string ("***", "**", "*", or "ns").
|
|
220
|
-
"""
|
|
221
|
-
if p_value is None:
|
|
222
|
-
return "ns"
|
|
223
|
-
|
|
224
|
-
for threshold, stars in self.alpha_thresholds:
|
|
225
|
-
if p_value < threshold:
|
|
226
|
-
return stars
|
|
227
|
-
return "ns"
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
# =============================================================================
|
|
231
|
-
# APA Style (LaTeX)
|
|
232
|
-
# =============================================================================
|
|
233
|
-
|
|
234
|
-
APA_LATEX_STYLE = StatStyle(
|
|
235
|
-
id="apa_latex",
|
|
236
|
-
label="APA (LaTeX)",
|
|
237
|
-
target="latex",
|
|
238
|
-
stat_symbol_format={
|
|
239
|
-
"t": "\\mathit{t}",
|
|
240
|
-
"F": "\\mathit{F}",
|
|
241
|
-
"chi2": "\\chi^2",
|
|
242
|
-
"U": "\\mathit{U}",
|
|
243
|
-
"W": "\\mathit{W}",
|
|
244
|
-
"BM": "\\mathit{BM}",
|
|
245
|
-
"r": "\\mathit{r}",
|
|
246
|
-
"n": "\\mathit{n}",
|
|
247
|
-
"p": "\\mathit{p}",
|
|
248
|
-
},
|
|
249
|
-
p_format="\\mathit{p} = {p:.3f}",
|
|
250
|
-
alpha_thresholds=[
|
|
251
|
-
(0.001, "***"),
|
|
252
|
-
(0.01, "**"),
|
|
253
|
-
(0.05, "*"),
|
|
254
|
-
],
|
|
255
|
-
effect_label_format={
|
|
256
|
-
"cohens_d_ind": "Cohen's~d",
|
|
257
|
-
"cohens_d_paired": "Cohen's~d",
|
|
258
|
-
"hedges_g": "Hedges'~g",
|
|
259
|
-
"cliffs_delta": "Cliff's~$\\delta$",
|
|
260
|
-
"eta_squared": "$\\eta^2$",
|
|
261
|
-
"partial_eta_squared": "$\\eta^2_{p}$",
|
|
262
|
-
"effect_size_r": "\\mathit{r}",
|
|
263
|
-
"odds_ratio": "OR",
|
|
264
|
-
"risk_ratio": "RR",
|
|
265
|
-
"prob_superiority": "P(X>Y)",
|
|
266
|
-
},
|
|
267
|
-
n_format="\\mathit{n}_{%s} = %d",
|
|
268
|
-
decimal_places_p=3,
|
|
269
|
-
decimal_places_stat=2,
|
|
270
|
-
decimal_places_effect=2,
|
|
271
|
-
)
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
# =============================================================================
|
|
275
|
-
# APA Style (HTML)
|
|
276
|
-
# =============================================================================
|
|
277
|
-
|
|
278
|
-
APA_HTML_STYLE = StatStyle(
|
|
279
|
-
id="apa_html",
|
|
280
|
-
label="APA (HTML)",
|
|
281
|
-
target="html",
|
|
282
|
-
stat_symbol_format={
|
|
283
|
-
"t": "<i>t</i>",
|
|
284
|
-
"F": "<i>F</i>",
|
|
285
|
-
"chi2": "<i>χ</i><sup>2</sup>",
|
|
286
|
-
"U": "<i>U</i>",
|
|
287
|
-
"W": "<i>W</i>",
|
|
288
|
-
"BM": "<i>BM</i>",
|
|
289
|
-
"r": "<i>r</i>",
|
|
290
|
-
"n": "<i>n</i>",
|
|
291
|
-
"p": "<i>p</i>",
|
|
292
|
-
},
|
|
293
|
-
p_format="<i>p</i> = {p:.3f}",
|
|
294
|
-
alpha_thresholds=[
|
|
295
|
-
(0.001, "***"),
|
|
296
|
-
(0.01, "**"),
|
|
297
|
-
(0.05, "*"),
|
|
298
|
-
],
|
|
299
|
-
effect_label_format={
|
|
300
|
-
"cohens_d_ind": "Cohen's d",
|
|
301
|
-
"cohens_d_paired": "Cohen's d",
|
|
302
|
-
"hedges_g": "Hedges' g",
|
|
303
|
-
"cliffs_delta": "Cliff's δ",
|
|
304
|
-
"eta_squared": "η<sup>2</sup>",
|
|
305
|
-
"partial_eta_squared": "η<sup>2</sup><sub>p</sub>",
|
|
306
|
-
"effect_size_r": "<i>r</i>",
|
|
307
|
-
"odds_ratio": "OR",
|
|
308
|
-
"risk_ratio": "RR",
|
|
309
|
-
"prob_superiority": "P(X>Y)",
|
|
310
|
-
},
|
|
311
|
-
n_format="<i>n</i><sub>%s</sub> = %d",
|
|
312
|
-
decimal_places_p=3,
|
|
313
|
-
decimal_places_stat=2,
|
|
314
|
-
decimal_places_effect=2,
|
|
315
|
-
)
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
# =============================================================================
|
|
319
|
-
# Nature Style (LaTeX)
|
|
320
|
-
# =============================================================================
|
|
321
|
-
|
|
322
|
-
NATURE_LATEX_STYLE = StatStyle(
|
|
323
|
-
id="nature_latex",
|
|
324
|
-
label="Nature (LaTeX)",
|
|
325
|
-
target="latex",
|
|
326
|
-
stat_symbol_format={
|
|
327
|
-
"t": "\\mathit{t}",
|
|
328
|
-
"F": "\\mathit{F}",
|
|
329
|
-
"chi2": "\\chi^2",
|
|
330
|
-
"U": "\\mathit{U}",
|
|
331
|
-
"W": "\\mathit{W}",
|
|
332
|
-
"BM": "\\mathit{BM}",
|
|
333
|
-
"r": "\\mathit{r}",
|
|
334
|
-
"n": "\\mathit{n}",
|
|
335
|
-
# Nature often uses uppercase P
|
|
336
|
-
"p": "\\mathit{P}",
|
|
337
|
-
},
|
|
338
|
-
# 3 significant figures
|
|
339
|
-
p_format="\\mathit{P} = {p:.3g}",
|
|
340
|
-
alpha_thresholds=[
|
|
341
|
-
(0.001, "***"),
|
|
342
|
-
(0.01, "**"),
|
|
343
|
-
(0.05, "*"),
|
|
344
|
-
],
|
|
345
|
-
effect_label_format={
|
|
346
|
-
"cohens_d_ind": "Cohen's~d",
|
|
347
|
-
"cohens_d_paired": "Cohen's~d",
|
|
348
|
-
"hedges_g": "Hedges'~g",
|
|
349
|
-
"cliffs_delta": "Cliff's~$\\delta$",
|
|
350
|
-
"eta_squared": "$\\eta^2$",
|
|
351
|
-
"partial_eta_squared": "$\\eta^2_{p}$",
|
|
352
|
-
"effect_size_r": "\\mathit{r}",
|
|
353
|
-
"odds_ratio": "OR",
|
|
354
|
-
"risk_ratio": "RR",
|
|
355
|
-
"prob_superiority": "P(X>Y)",
|
|
356
|
-
},
|
|
357
|
-
# Nature often shows total n rather than per-group
|
|
358
|
-
n_format="\\mathit{n} = %d",
|
|
359
|
-
decimal_places_p=3,
|
|
360
|
-
decimal_places_stat=2,
|
|
361
|
-
decimal_places_effect=2,
|
|
362
|
-
)
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
# =============================================================================
|
|
366
|
-
# Nature Style (HTML)
|
|
367
|
-
# =============================================================================
|
|
368
|
-
|
|
369
|
-
NATURE_HTML_STYLE = StatStyle(
|
|
370
|
-
id="nature_html",
|
|
371
|
-
label="Nature (HTML)",
|
|
372
|
-
target="html",
|
|
373
|
-
stat_symbol_format={
|
|
374
|
-
"t": "<i>t</i>",
|
|
375
|
-
"F": "<i>F</i>",
|
|
376
|
-
"chi2": "<i>χ</i><sup>2</sup>",
|
|
377
|
-
"U": "<i>U</i>",
|
|
378
|
-
"W": "<i>W</i>",
|
|
379
|
-
"BM": "<i>BM</i>",
|
|
380
|
-
"r": "<i>r</i>",
|
|
381
|
-
"n": "<i>n</i>",
|
|
382
|
-
"p": "<i>P</i>", # Capital P
|
|
383
|
-
},
|
|
384
|
-
p_format="<i>P</i> = {p:.3g}",
|
|
385
|
-
alpha_thresholds=[
|
|
386
|
-
(0.001, "***"),
|
|
387
|
-
(0.01, "**"),
|
|
388
|
-
(0.05, "*"),
|
|
389
|
-
],
|
|
390
|
-
effect_label_format={
|
|
391
|
-
"cohens_d_ind": "Cohen's d",
|
|
392
|
-
"cohens_d_paired": "Cohen's d",
|
|
393
|
-
"hedges_g": "Hedges' g",
|
|
394
|
-
"cliffs_delta": "Cliff's δ",
|
|
395
|
-
"eta_squared": "η<sup>2</sup>",
|
|
396
|
-
"partial_eta_squared": "η<sup>2</sup><sub>p</sub>",
|
|
397
|
-
"effect_size_r": "<i>r</i>",
|
|
398
|
-
"odds_ratio": "OR",
|
|
399
|
-
"risk_ratio": "RR",
|
|
400
|
-
"prob_superiority": "P(X>Y)",
|
|
401
|
-
},
|
|
402
|
-
n_format="<i>n</i> = %d",
|
|
403
|
-
decimal_places_p=3,
|
|
404
|
-
decimal_places_stat=2,
|
|
405
|
-
decimal_places_effect=2,
|
|
22
|
+
from typing import Dict, List, Optional
|
|
23
|
+
|
|
24
|
+
from ._stat_style import OutputTarget, StatStyle
|
|
25
|
+
from ._style_definitions import (
|
|
26
|
+
APA_HTML_STYLE,
|
|
27
|
+
APA_LATEX_STYLE,
|
|
28
|
+
CELL_HTML_STYLE,
|
|
29
|
+
CELL_LATEX_STYLE,
|
|
30
|
+
ELSEVIER_HTML_STYLE,
|
|
31
|
+
ELSEVIER_LATEX_STYLE,
|
|
32
|
+
NATURE_HTML_STYLE,
|
|
33
|
+
NATURE_LATEX_STYLE,
|
|
34
|
+
PLAIN_STYLE,
|
|
406
35
|
)
|
|
407
36
|
|
|
408
|
-
|
|
409
|
-
# =============================================================================
|
|
410
|
-
# Cell Press Style (LaTeX)
|
|
411
|
-
# =============================================================================
|
|
412
|
-
|
|
413
|
-
CELL_LATEX_STYLE = StatStyle(
|
|
414
|
-
id="cell_latex",
|
|
415
|
-
label="Cell (LaTeX)",
|
|
416
|
-
target="latex",
|
|
417
|
-
stat_symbol_format={
|
|
418
|
-
"t": "\\mathit{t}",
|
|
419
|
-
"F": "\\mathit{F}",
|
|
420
|
-
"chi2": "\\chi^2",
|
|
421
|
-
"U": "\\mathit{U}",
|
|
422
|
-
"W": "\\mathit{W}",
|
|
423
|
-
"BM": "\\mathit{BM}",
|
|
424
|
-
"r": "\\mathit{r}",
|
|
425
|
-
"n": "\\mathit{n}",
|
|
426
|
-
"p": "\\mathit{p}",
|
|
427
|
-
},
|
|
428
|
-
p_format="\\mathit{p} = {p:.3g}",
|
|
429
|
-
# Cell often uses **** for p < 0.0001
|
|
430
|
-
alpha_thresholds=[
|
|
431
|
-
(0.0001, "****"),
|
|
432
|
-
(0.001, "***"),
|
|
433
|
-
(0.01, "**"),
|
|
434
|
-
(0.05, "*"),
|
|
435
|
-
],
|
|
436
|
-
effect_label_format={
|
|
437
|
-
"cohens_d_ind": "Cohen's~d",
|
|
438
|
-
"cohens_d_paired": "Cohen's~d",
|
|
439
|
-
"hedges_g": "Hedges'~g",
|
|
440
|
-
"cliffs_delta": "Cliff's~$\\delta$",
|
|
441
|
-
"eta_squared": "$\\eta^2$",
|
|
442
|
-
"partial_eta_squared": "$\\eta^2_{p}$",
|
|
443
|
-
"effect_size_r": "\\mathit{r}",
|
|
444
|
-
"odds_ratio": "OR",
|
|
445
|
-
"risk_ratio": "RR",
|
|
446
|
-
"prob_superiority": "P(X>Y)",
|
|
447
|
-
},
|
|
448
|
-
# Cell often uses "n = X cells from Y mice" style
|
|
449
|
-
n_format="\\mathit{n} = %d",
|
|
450
|
-
decimal_places_p=3,
|
|
451
|
-
decimal_places_stat=2,
|
|
452
|
-
decimal_places_effect=2,
|
|
453
|
-
)
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
# =============================================================================
|
|
457
|
-
# Cell Press Style (HTML)
|
|
458
|
-
# =============================================================================
|
|
459
|
-
|
|
460
|
-
CELL_HTML_STYLE = StatStyle(
|
|
461
|
-
id="cell_html",
|
|
462
|
-
label="Cell (HTML)",
|
|
463
|
-
target="html",
|
|
464
|
-
stat_symbol_format={
|
|
465
|
-
"t": "<i>t</i>",
|
|
466
|
-
"F": "<i>F</i>",
|
|
467
|
-
"chi2": "<i>χ</i><sup>2</sup>",
|
|
468
|
-
"U": "<i>U</i>",
|
|
469
|
-
"W": "<i>W</i>",
|
|
470
|
-
"BM": "<i>BM</i>",
|
|
471
|
-
"r": "<i>r</i>",
|
|
472
|
-
"n": "<i>n</i>",
|
|
473
|
-
"p": "<i>p</i>",
|
|
474
|
-
},
|
|
475
|
-
p_format="<i>p</i> = {p:.3g}",
|
|
476
|
-
alpha_thresholds=[
|
|
477
|
-
(0.0001, "****"),
|
|
478
|
-
(0.001, "***"),
|
|
479
|
-
(0.01, "**"),
|
|
480
|
-
(0.05, "*"),
|
|
481
|
-
],
|
|
482
|
-
effect_label_format={
|
|
483
|
-
"cohens_d_ind": "Cohen's d",
|
|
484
|
-
"cohens_d_paired": "Cohen's d",
|
|
485
|
-
"hedges_g": "Hedges' g",
|
|
486
|
-
"cliffs_delta": "Cliff's δ",
|
|
487
|
-
"eta_squared": "η<sup>2</sup>",
|
|
488
|
-
"partial_eta_squared": "η<sup>2</sup><sub>p</sub>",
|
|
489
|
-
"effect_size_r": "<i>r</i>",
|
|
490
|
-
"odds_ratio": "OR",
|
|
491
|
-
"risk_ratio": "RR",
|
|
492
|
-
"prob_superiority": "P(X>Y)",
|
|
493
|
-
},
|
|
494
|
-
n_format="<i>n</i> = %d",
|
|
495
|
-
decimal_places_p=3,
|
|
496
|
-
decimal_places_stat=2,
|
|
497
|
-
decimal_places_effect=2,
|
|
498
|
-
)
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
# =============================================================================
|
|
502
|
-
# Elsevier Style (LaTeX)
|
|
503
|
-
# =============================================================================
|
|
504
|
-
|
|
505
|
-
ELSEVIER_LATEX_STYLE = StatStyle(
|
|
506
|
-
id="elsevier_latex",
|
|
507
|
-
label="Elsevier (LaTeX)",
|
|
508
|
-
target="latex",
|
|
509
|
-
stat_symbol_format={
|
|
510
|
-
"t": "\\mathit{t}",
|
|
511
|
-
"F": "\\mathit{F}",
|
|
512
|
-
"chi2": "\\chi^2",
|
|
513
|
-
"U": "\\mathit{U}",
|
|
514
|
-
"W": "\\mathit{W}",
|
|
515
|
-
"BM": "\\mathit{BM}",
|
|
516
|
-
"r": "\\mathit{r}",
|
|
517
|
-
"n": "\\mathit{n}",
|
|
518
|
-
"p": "\\mathit{p}",
|
|
519
|
-
},
|
|
520
|
-
p_format="\\mathit{p} = {p:.3f}",
|
|
521
|
-
alpha_thresholds=[
|
|
522
|
-
(0.001, "***"),
|
|
523
|
-
(0.01, "**"),
|
|
524
|
-
(0.05, "*"),
|
|
525
|
-
],
|
|
526
|
-
effect_label_format={
|
|
527
|
-
"cohens_d_ind": "Cohen's~d",
|
|
528
|
-
"cohens_d_paired": "Cohen's~d",
|
|
529
|
-
"hedges_g": "Hedges'~g",
|
|
530
|
-
"cliffs_delta": "Cliff's~$\\delta$",
|
|
531
|
-
"eta_squared": "$\\eta^2$",
|
|
532
|
-
"partial_eta_squared": "$\\eta^2_{p}$",
|
|
533
|
-
"effect_size_r": "\\mathit{r}",
|
|
534
|
-
"odds_ratio": "OR",
|
|
535
|
-
"risk_ratio": "RR",
|
|
536
|
-
"prob_superiority": "P(X>Y)",
|
|
537
|
-
},
|
|
538
|
-
n_format="\\mathit{n} = %d",
|
|
539
|
-
decimal_places_p=3,
|
|
540
|
-
decimal_places_stat=2,
|
|
541
|
-
decimal_places_effect=2,
|
|
542
|
-
)
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
# =============================================================================
|
|
546
|
-
# Elsevier Style (HTML)
|
|
547
|
-
# =============================================================================
|
|
548
|
-
|
|
549
|
-
ELSEVIER_HTML_STYLE = StatStyle(
|
|
550
|
-
id="elsevier_html",
|
|
551
|
-
label="Elsevier (HTML)",
|
|
552
|
-
target="html",
|
|
553
|
-
stat_symbol_format={
|
|
554
|
-
"t": "<i>t</i>",
|
|
555
|
-
"F": "<i>F</i>",
|
|
556
|
-
"chi2": "<i>χ</i><sup>2</sup>",
|
|
557
|
-
"U": "<i>U</i>",
|
|
558
|
-
"W": "<i>W</i>",
|
|
559
|
-
"BM": "<i>BM</i>",
|
|
560
|
-
"r": "<i>r</i>",
|
|
561
|
-
"n": "<i>n</i>",
|
|
562
|
-
"p": "<i>p</i>",
|
|
563
|
-
},
|
|
564
|
-
p_format="<i>p</i> = {p:.3f}",
|
|
565
|
-
alpha_thresholds=[
|
|
566
|
-
(0.001, "***"),
|
|
567
|
-
(0.01, "**"),
|
|
568
|
-
(0.05, "*"),
|
|
569
|
-
],
|
|
570
|
-
effect_label_format={
|
|
571
|
-
"cohens_d_ind": "Cohen's d",
|
|
572
|
-
"cohens_d_paired": "Cohen's d",
|
|
573
|
-
"hedges_g": "Hedges' g",
|
|
574
|
-
"cliffs_delta": "Cliff's δ",
|
|
575
|
-
"eta_squared": "η<sup>2</sup>",
|
|
576
|
-
"partial_eta_squared": "η<sup>2</sup><sub>p</sub>",
|
|
577
|
-
"effect_size_r": "<i>r</i>",
|
|
578
|
-
"odds_ratio": "OR",
|
|
579
|
-
"risk_ratio": "RR",
|
|
580
|
-
"prob_superiority": "P(X>Y)",
|
|
581
|
-
},
|
|
582
|
-
n_format="<i>n</i> = %d",
|
|
583
|
-
decimal_places_p=3,
|
|
584
|
-
decimal_places_stat=2,
|
|
585
|
-
decimal_places_effect=2,
|
|
586
|
-
)
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
# =============================================================================
|
|
590
|
-
# Plain Text Style
|
|
591
|
-
# =============================================================================
|
|
592
|
-
|
|
593
|
-
PLAIN_STYLE = StatStyle(
|
|
594
|
-
id="plain",
|
|
595
|
-
label="Plain Text",
|
|
596
|
-
target="plain",
|
|
597
|
-
stat_symbol_format={
|
|
598
|
-
"t": "t",
|
|
599
|
-
"F": "F",
|
|
600
|
-
"chi2": "chi2",
|
|
601
|
-
"U": "U",
|
|
602
|
-
"W": "W",
|
|
603
|
-
"BM": "BM",
|
|
604
|
-
"r": "r",
|
|
605
|
-
"n": "n",
|
|
606
|
-
"p": "p",
|
|
607
|
-
},
|
|
608
|
-
p_format="p = {p:.3f}",
|
|
609
|
-
alpha_thresholds=[
|
|
610
|
-
(0.001, "***"),
|
|
611
|
-
(0.01, "**"),
|
|
612
|
-
(0.05, "*"),
|
|
613
|
-
],
|
|
614
|
-
effect_label_format={
|
|
615
|
-
"cohens_d_ind": "Cohen's d",
|
|
616
|
-
"cohens_d_paired": "Cohen's d",
|
|
617
|
-
"hedges_g": "Hedges' g",
|
|
618
|
-
"cliffs_delta": "Cliff's delta",
|
|
619
|
-
"eta_squared": "eta^2",
|
|
620
|
-
"partial_eta_squared": "partial eta^2",
|
|
621
|
-
"effect_size_r": "r",
|
|
622
|
-
"odds_ratio": "OR",
|
|
623
|
-
"risk_ratio": "RR",
|
|
624
|
-
"prob_superiority": "P(X>Y)",
|
|
625
|
-
},
|
|
626
|
-
n_format="n_%s = %d",
|
|
627
|
-
decimal_places_p=3,
|
|
628
|
-
decimal_places_stat=2,
|
|
629
|
-
decimal_places_effect=2,
|
|
630
|
-
)
|
|
631
|
-
|
|
632
|
-
|
|
633
37
|
# =============================================================================
|
|
634
38
|
# Style Registry
|
|
635
39
|
# =============================================================================
|
|
@@ -648,8 +52,7 @@ STAT_STYLES: Dict[str, StatStyle] = {
|
|
|
648
52
|
|
|
649
53
|
|
|
650
54
|
def get_stat_style(style_id: str) -> StatStyle:
|
|
651
|
-
"""
|
|
652
|
-
Look up a statistical reporting style by its ID.
|
|
55
|
+
"""Look up a statistical reporting style by its ID.
|
|
653
56
|
|
|
654
57
|
Parameters
|
|
655
58
|
----------
|
|
@@ -675,8 +78,7 @@ def get_stat_style(style_id: str) -> StatStyle:
|
|
|
675
78
|
|
|
676
79
|
|
|
677
80
|
def list_styles(target: Optional[OutputTarget] = None) -> List[str]:
|
|
678
|
-
"""
|
|
679
|
-
List available style IDs.
|
|
81
|
+
"""List available style IDs.
|
|
680
82
|
|
|
681
83
|
Parameters
|
|
682
84
|
----------
|
|
@@ -690,10 +92,7 @@ def list_styles(target: Optional[OutputTarget] = None) -> List[str]:
|
|
|
690
92
|
"""
|
|
691
93
|
if target is None:
|
|
692
94
|
return list(STAT_STYLES.keys())
|
|
693
|
-
return [
|
|
694
|
-
sid for sid, style in STAT_STYLES.items()
|
|
695
|
-
if style.target == target
|
|
696
|
-
]
|
|
95
|
+
return [sid for sid, style in STAT_STYLES.items() if style.target == target]
|
|
697
96
|
|
|
698
97
|
|
|
699
98
|
# =============================================================================
|
|
@@ -701,8 +100,10 @@ def list_styles(target: Optional[OutputTarget] = None) -> List[str]:
|
|
|
701
100
|
# =============================================================================
|
|
702
101
|
|
|
703
102
|
__all__ = [
|
|
103
|
+
# Core types
|
|
704
104
|
"StatStyle",
|
|
705
105
|
"OutputTarget",
|
|
106
|
+
# Registry and helpers
|
|
706
107
|
"STAT_STYLES",
|
|
707
108
|
"get_stat_style",
|
|
708
109
|
"list_styles",
|
|
@@ -718,4 +119,5 @@ __all__ = [
|
|
|
718
119
|
"PLAIN_STYLE",
|
|
719
120
|
]
|
|
720
121
|
|
|
122
|
+
|
|
721
123
|
# EOF
|