scitex 2.14.0__py3-none-any.whl → 2.15.3__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.
Files changed (264) hide show
  1. scitex/__init__.py +71 -17
  2. scitex/_env_loader.py +156 -0
  3. scitex/_mcp_resources/__init__.py +37 -0
  4. scitex/_mcp_resources/_cheatsheet.py +135 -0
  5. scitex/_mcp_resources/_figrecipe.py +138 -0
  6. scitex/_mcp_resources/_formats.py +102 -0
  7. scitex/_mcp_resources/_modules.py +337 -0
  8. scitex/_mcp_resources/_session.py +149 -0
  9. scitex/_mcp_tools/__init__.py +4 -0
  10. scitex/_mcp_tools/audio.py +66 -0
  11. scitex/_mcp_tools/diagram.py +11 -95
  12. scitex/_mcp_tools/introspect.py +210 -0
  13. scitex/_mcp_tools/plt.py +260 -305
  14. scitex/_mcp_tools/scholar.py +74 -0
  15. scitex/_mcp_tools/social.py +27 -0
  16. scitex/_mcp_tools/template.py +24 -0
  17. scitex/_mcp_tools/writer.py +17 -210
  18. scitex/ai/_gen_ai/_PARAMS.py +10 -7
  19. scitex/ai/classification/reporters/_SingleClassificationReporter.py +45 -1603
  20. scitex/ai/classification/reporters/_mixins/__init__.py +36 -0
  21. scitex/ai/classification/reporters/_mixins/_constants.py +67 -0
  22. scitex/ai/classification/reporters/_mixins/_cv_summary.py +387 -0
  23. scitex/ai/classification/reporters/_mixins/_feature_importance.py +119 -0
  24. scitex/ai/classification/reporters/_mixins/_metrics.py +275 -0
  25. scitex/ai/classification/reporters/_mixins/_plotting.py +179 -0
  26. scitex/ai/classification/reporters/_mixins/_reports.py +153 -0
  27. scitex/ai/classification/reporters/_mixins/_storage.py +160 -0
  28. scitex/ai/classification/timeseries/_TimeSeriesSlidingWindowSplit.py +30 -1550
  29. scitex/ai/classification/timeseries/_sliding_window_core.py +467 -0
  30. scitex/ai/classification/timeseries/_sliding_window_plotting.py +369 -0
  31. scitex/audio/README.md +40 -36
  32. scitex/audio/__init__.py +129 -61
  33. scitex/audio/_branding.py +185 -0
  34. scitex/audio/_mcp/__init__.py +32 -0
  35. scitex/audio/_mcp/handlers.py +59 -6
  36. scitex/audio/_mcp/speak_handlers.py +238 -0
  37. scitex/audio/_relay.py +225 -0
  38. scitex/audio/_tts.py +18 -10
  39. scitex/audio/engines/base.py +17 -10
  40. scitex/audio/engines/elevenlabs_engine.py +7 -2
  41. scitex/audio/mcp_server.py +228 -75
  42. scitex/canvas/README.md +1 -1
  43. scitex/canvas/editor/_dearpygui/__init__.py +25 -0
  44. scitex/canvas/editor/_dearpygui/_editor.py +147 -0
  45. scitex/canvas/editor/_dearpygui/_handlers.py +476 -0
  46. scitex/canvas/editor/_dearpygui/_panels/__init__.py +17 -0
  47. scitex/canvas/editor/_dearpygui/_panels/_control.py +119 -0
  48. scitex/canvas/editor/_dearpygui/_panels/_element_controls.py +190 -0
  49. scitex/canvas/editor/_dearpygui/_panels/_preview.py +43 -0
  50. scitex/canvas/editor/_dearpygui/_panels/_sections.py +390 -0
  51. scitex/canvas/editor/_dearpygui/_plotting.py +187 -0
  52. scitex/canvas/editor/_dearpygui/_rendering.py +504 -0
  53. scitex/canvas/editor/_dearpygui/_selection.py +295 -0
  54. scitex/canvas/editor/_dearpygui/_state.py +93 -0
  55. scitex/canvas/editor/_dearpygui/_utils.py +61 -0
  56. scitex/canvas/editor/flask_editor/_core/__init__.py +27 -0
  57. scitex/canvas/editor/flask_editor/_core/_bbox_extraction.py +200 -0
  58. scitex/canvas/editor/flask_editor/_core/_editor.py +173 -0
  59. scitex/canvas/editor/flask_editor/_core/_export_helpers.py +353 -0
  60. scitex/canvas/editor/flask_editor/_core/_routes_basic.py +190 -0
  61. scitex/canvas/editor/flask_editor/_core/_routes_export.py +332 -0
  62. scitex/canvas/editor/flask_editor/_core/_routes_panels.py +252 -0
  63. scitex/canvas/editor/flask_editor/_core/_routes_save.py +218 -0
  64. scitex/canvas/editor/flask_editor/_core.py +25 -1684
  65. scitex/canvas/editor/flask_editor/templates/__init__.py +32 -70
  66. scitex/cli/__init__.py +38 -43
  67. scitex/cli/audio.py +160 -41
  68. scitex/cli/capture.py +133 -20
  69. scitex/cli/introspect.py +488 -0
  70. scitex/cli/main.py +200 -109
  71. scitex/cli/mcp.py +60 -34
  72. scitex/cli/plt.py +414 -0
  73. scitex/cli/repro.py +15 -8
  74. scitex/cli/resource.py +15 -8
  75. scitex/cli/scholar/__init__.py +154 -8
  76. scitex/cli/scholar/_crossref_scitex.py +296 -0
  77. scitex/cli/scholar/_fetch.py +25 -3
  78. scitex/cli/social.py +355 -0
  79. scitex/cli/stats.py +136 -11
  80. scitex/cli/template.py +129 -12
  81. scitex/cli/tex.py +15 -8
  82. scitex/cli/writer.py +49 -299
  83. scitex/cloud/__init__.py +41 -2
  84. scitex/config/README.md +1 -1
  85. scitex/config/__init__.py +16 -2
  86. scitex/config/_env_registry.py +256 -0
  87. scitex/context/__init__.py +22 -0
  88. scitex/dev/__init__.py +20 -1
  89. scitex/diagram/__init__.py +42 -19
  90. scitex/diagram/mcp_server.py +13 -125
  91. scitex/gen/__init__.py +50 -14
  92. scitex/gen/_list_packages.py +4 -4
  93. scitex/introspect/__init__.py +82 -0
  94. scitex/introspect/_call_graph.py +303 -0
  95. scitex/introspect/_class_hierarchy.py +163 -0
  96. scitex/introspect/_core.py +41 -0
  97. scitex/introspect/_docstring.py +131 -0
  98. scitex/introspect/_examples.py +113 -0
  99. scitex/introspect/_imports.py +271 -0
  100. scitex/{gen/_inspect_module.py → introspect/_list_api.py} +48 -56
  101. scitex/introspect/_mcp/__init__.py +41 -0
  102. scitex/introspect/_mcp/handlers.py +233 -0
  103. scitex/introspect/_members.py +155 -0
  104. scitex/introspect/_resolve.py +89 -0
  105. scitex/introspect/_signature.py +131 -0
  106. scitex/introspect/_source.py +80 -0
  107. scitex/introspect/_type_hints.py +172 -0
  108. scitex/io/_save.py +1 -2
  109. scitex/io/bundle/README.md +1 -1
  110. scitex/logging/_formatters.py +19 -9
  111. scitex/mcp_server.py +98 -5
  112. scitex/os/__init__.py +4 -0
  113. scitex/{gen → os}/_check_host.py +4 -5
  114. scitex/plt/__init__.py +245 -550
  115. scitex/plt/_subplots/_AxisWrapperMixins/_SeabornMixin/_wrappers.py +5 -10
  116. scitex/plt/docs/EXTERNAL_PACKAGE_BRANDING.md +149 -0
  117. scitex/plt/gallery/README.md +1 -1
  118. scitex/plt/utils/_hitmap/__init__.py +82 -0
  119. scitex/plt/utils/_hitmap/_artist_extraction.py +343 -0
  120. scitex/plt/utils/_hitmap/_color_application.py +346 -0
  121. scitex/plt/utils/_hitmap/_color_conversion.py +121 -0
  122. scitex/plt/utils/_hitmap/_constants.py +40 -0
  123. scitex/plt/utils/_hitmap/_hitmap_core.py +334 -0
  124. scitex/plt/utils/_hitmap/_path_extraction.py +357 -0
  125. scitex/plt/utils/_hitmap/_query.py +113 -0
  126. scitex/plt/utils/_hitmap.py +46 -1616
  127. scitex/plt/utils/_metadata/__init__.py +80 -0
  128. scitex/plt/utils/_metadata/_artists/__init__.py +25 -0
  129. scitex/plt/utils/_metadata/_artists/_base.py +195 -0
  130. scitex/plt/utils/_metadata/_artists/_collections.py +356 -0
  131. scitex/plt/utils/_metadata/_artists/_extract.py +57 -0
  132. scitex/plt/utils/_metadata/_artists/_images.py +80 -0
  133. scitex/plt/utils/_metadata/_artists/_lines.py +261 -0
  134. scitex/plt/utils/_metadata/_artists/_patches.py +247 -0
  135. scitex/plt/utils/_metadata/_artists/_text.py +106 -0
  136. scitex/plt/utils/_metadata/_csv.py +416 -0
  137. scitex/plt/utils/_metadata/_detect.py +225 -0
  138. scitex/plt/utils/_metadata/_legend.py +127 -0
  139. scitex/plt/utils/_metadata/_rounding.py +117 -0
  140. scitex/plt/utils/_metadata/_verification.py +202 -0
  141. scitex/schema/README.md +1 -1
  142. scitex/scholar/__init__.py +8 -0
  143. scitex/scholar/_mcp/crossref_handlers.py +265 -0
  144. scitex/scholar/core/Scholar.py +63 -1700
  145. scitex/scholar/core/_mixins/__init__.py +36 -0
  146. scitex/scholar/core/_mixins/_enrichers.py +270 -0
  147. scitex/scholar/core/_mixins/_library_handlers.py +100 -0
  148. scitex/scholar/core/_mixins/_loaders.py +103 -0
  149. scitex/scholar/core/_mixins/_pdf_download.py +375 -0
  150. scitex/scholar/core/_mixins/_pipeline.py +312 -0
  151. scitex/scholar/core/_mixins/_project_handlers.py +125 -0
  152. scitex/scholar/core/_mixins/_savers.py +69 -0
  153. scitex/scholar/core/_mixins/_search.py +103 -0
  154. scitex/scholar/core/_mixins/_services.py +88 -0
  155. scitex/scholar/core/_mixins/_url_finding.py +105 -0
  156. scitex/scholar/crossref_scitex.py +367 -0
  157. scitex/scholar/docs/EXTERNAL_PACKAGE_BRANDING.md +149 -0
  158. scitex/scholar/examples/00_run_all.sh +120 -0
  159. scitex/scholar/jobs/_executors.py +27 -3
  160. scitex/scholar/pdf_download/ScholarPDFDownloader.py +38 -416
  161. scitex/scholar/pdf_download/_cli.py +154 -0
  162. scitex/scholar/pdf_download/strategies/__init__.py +11 -8
  163. scitex/scholar/pdf_download/strategies/manual_download_fallback.py +80 -3
  164. scitex/scholar/pipelines/ScholarPipelineBibTeX.py +73 -121
  165. scitex/scholar/pipelines/ScholarPipelineParallel.py +80 -138
  166. scitex/scholar/pipelines/ScholarPipelineSingle.py +43 -63
  167. scitex/scholar/pipelines/_single_steps.py +71 -36
  168. scitex/scholar/storage/_LibraryManager.py +97 -1695
  169. scitex/scholar/storage/_mixins/__init__.py +30 -0
  170. scitex/scholar/storage/_mixins/_bibtex_handlers.py +128 -0
  171. scitex/scholar/storage/_mixins/_library_operations.py +218 -0
  172. scitex/scholar/storage/_mixins/_metadata_conversion.py +226 -0
  173. scitex/scholar/storage/_mixins/_paper_saving.py +456 -0
  174. scitex/scholar/storage/_mixins/_resolution.py +376 -0
  175. scitex/scholar/storage/_mixins/_storage_helpers.py +121 -0
  176. scitex/scholar/storage/_mixins/_symlink_handlers.py +226 -0
  177. scitex/security/README.md +3 -3
  178. scitex/session/README.md +1 -1
  179. scitex/session/__init__.py +26 -7
  180. scitex/session/_decorator.py +1 -1
  181. scitex/sh/README.md +1 -1
  182. scitex/sh/__init__.py +7 -4
  183. scitex/social/__init__.py +155 -0
  184. scitex/social/docs/EXTERNAL_PACKAGE_BRANDING.md +149 -0
  185. scitex/stats/_mcp/_handlers/__init__.py +31 -0
  186. scitex/stats/_mcp/_handlers/_corrections.py +113 -0
  187. scitex/stats/_mcp/_handlers/_descriptive.py +78 -0
  188. scitex/stats/_mcp/_handlers/_effect_size.py +106 -0
  189. scitex/stats/_mcp/_handlers/_format.py +94 -0
  190. scitex/stats/_mcp/_handlers/_normality.py +110 -0
  191. scitex/stats/_mcp/_handlers/_posthoc.py +224 -0
  192. scitex/stats/_mcp/_handlers/_power.py +247 -0
  193. scitex/stats/_mcp/_handlers/_recommend.py +102 -0
  194. scitex/stats/_mcp/_handlers/_run_test.py +279 -0
  195. scitex/stats/_mcp/_handlers/_stars.py +48 -0
  196. scitex/stats/_mcp/handlers.py +19 -1171
  197. scitex/stats/auto/_stat_style.py +175 -0
  198. scitex/stats/auto/_style_definitions.py +411 -0
  199. scitex/stats/auto/_styles.py +22 -620
  200. scitex/stats/descriptive/__init__.py +11 -8
  201. scitex/stats/descriptive/_ci.py +39 -0
  202. scitex/stats/power/_power.py +15 -4
  203. scitex/str/__init__.py +2 -1
  204. scitex/str/_title_case.py +63 -0
  205. scitex/template/README.md +1 -1
  206. scitex/template/__init__.py +25 -10
  207. scitex/template/_code_templates.py +147 -0
  208. scitex/template/_mcp/handlers.py +81 -0
  209. scitex/template/_mcp/tool_schemas.py +55 -0
  210. scitex/template/_templates/__init__.py +51 -0
  211. scitex/template/_templates/audio.py +233 -0
  212. scitex/template/_templates/canvas.py +312 -0
  213. scitex/template/_templates/capture.py +268 -0
  214. scitex/template/_templates/config.py +43 -0
  215. scitex/template/_templates/diagram.py +294 -0
  216. scitex/template/_templates/io.py +107 -0
  217. scitex/template/_templates/module.py +53 -0
  218. scitex/template/_templates/plt.py +202 -0
  219. scitex/template/_templates/scholar.py +267 -0
  220. scitex/template/_templates/session.py +130 -0
  221. scitex/template/_templates/session_minimal.py +43 -0
  222. scitex/template/_templates/session_plot.py +67 -0
  223. scitex/template/_templates/session_stats.py +77 -0
  224. scitex/template/_templates/stats.py +323 -0
  225. scitex/template/_templates/writer.py +296 -0
  226. scitex/template/clone_writer_directory.py +5 -5
  227. scitex/ui/_backends/_email.py +10 -2
  228. scitex/ui/_backends/_webhook.py +5 -1
  229. scitex/web/_search_pubmed.py +10 -6
  230. scitex/writer/README.md +1 -1
  231. scitex/writer/__init__.py +43 -34
  232. scitex/writer/_mcp/handlers.py +11 -744
  233. scitex/writer/_mcp/tool_schemas.py +5 -335
  234. scitex-2.15.3.dist-info/METADATA +667 -0
  235. {scitex-2.14.0.dist-info → scitex-2.15.3.dist-info}/RECORD +241 -120
  236. scitex/canvas/editor/flask_editor/templates/_scripts.py +0 -4933
  237. scitex/canvas/editor/flask_editor/templates/_styles.py +0 -1658
  238. scitex/diagram/_compile.py +0 -312
  239. scitex/diagram/_diagram.py +0 -355
  240. scitex/diagram/_mcp/__init__.py +0 -4
  241. scitex/diagram/_mcp/handlers.py +0 -400
  242. scitex/diagram/_mcp/tool_schemas.py +0 -157
  243. scitex/diagram/_presets.py +0 -173
  244. scitex/diagram/_schema.py +0 -182
  245. scitex/diagram/_split.py +0 -278
  246. scitex/gen/_ci.py +0 -12
  247. scitex/gen/_title_case.py +0 -89
  248. scitex/plt/_mcp/__init__.py +0 -4
  249. scitex/plt/_mcp/_handlers_annotation.py +0 -102
  250. scitex/plt/_mcp/_handlers_figure.py +0 -195
  251. scitex/plt/_mcp/_handlers_plot.py +0 -252
  252. scitex/plt/_mcp/_handlers_style.py +0 -219
  253. scitex/plt/_mcp/handlers.py +0 -74
  254. scitex/plt/_mcp/tool_schemas.py +0 -497
  255. scitex/plt/mcp_server.py +0 -231
  256. scitex/scholar/examples/SUGGESTIONS.md +0 -865
  257. scitex/scholar/examples/dev.py +0 -38
  258. scitex-2.14.0.dist-info/METADATA +0 -1238
  259. /scitex/{gen → context}/_detect_environment.py +0 -0
  260. /scitex/{gen → context}/_get_notebook_path.py +0 -0
  261. /scitex/{gen/_shell.py → sh/_shell_legacy.py} +0 -0
  262. {scitex-2.14.0.dist-info → scitex-2.15.3.dist-info}/WHEEL +0 -0
  263. {scitex-2.14.0.dist-info → scitex-2.15.3.dist-info}/entry_points.txt +0 -0
  264. {scitex-2.14.0.dist-info → scitex-2.15.3.dist-info}/licenses/LICENSE +0 -0
@@ -1,10 +1,8 @@
1
1
  #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- # Timestamp: "2025-12-10 (ywatanabe)"
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 __future__ import annotations
25
-
26
- from dataclasses import dataclass, field
27
- from typing import Dict, List, Literal, Optional, Tuple, Any
28
-
29
- # =============================================================================
30
- # Type Aliases
31
- # =============================================================================
32
-
33
- OutputTarget = Literal["latex", "html", "plain"]
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>&chi;</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 &delta;",
304
- "eta_squared": "&eta;<sup>2</sup>",
305
- "partial_eta_squared": "&eta;<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>&chi;</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 &delta;",
395
- "eta_squared": "&eta;<sup>2</sup>",
396
- "partial_eta_squared": "&eta;<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>&chi;</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 &delta;",
487
- "eta_squared": "&eta;<sup>2</sup>",
488
- "partial_eta_squared": "&eta;<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>&chi;</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 &delta;",
575
- "eta_squared": "&eta;<sup>2</sup>",
576
- "partial_eta_squared": "&eta;<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