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
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env python3
2
+ """Standard Python module template."""
3
+
4
+ TEMPLATE = {
5
+ "name": "Python Module",
6
+ "description": "Standard Python module with docstring, type hints, and exports",
7
+ "filename": "module.py",
8
+ "usage": """
9
+ Usage:
10
+ from module import function_name
11
+ """,
12
+ "content": '''#!/usr/bin/env python3
13
+ # -*- coding: utf-8 -*-
14
+ # Timestamp: "{timestamp}"
15
+ # File: {filepath}
16
+
17
+ """
18
+ {docstring}
19
+ """
20
+
21
+ from typing import Optional
22
+
23
+
24
+ def function_name(arg1, kwarg1: Optional[str] = None):
25
+ """
26
+ Function description.
27
+
28
+ Parameters
29
+ ----------
30
+ arg1 : type
31
+ Description of arg1.
32
+ kwarg1 : str, optional
33
+ Description of kwarg1.
34
+
35
+ Returns
36
+ -------
37
+ type
38
+ Description of return value.
39
+
40
+ Examples
41
+ --------
42
+ >>> result = function_name(value)
43
+ """
44
+ pass
45
+
46
+
47
+ __all__ = ["function_name"]
48
+
49
+ # EOF
50
+ ''',
51
+ }
52
+
53
+ # EOF
@@ -0,0 +1,202 @@
1
+ #!/usr/bin/env python3
2
+ # Timestamp: 2026-01-25
3
+ # File: src/scitex/template/_templates/plt.py
4
+ # ----------------------------------------
5
+
6
+ """Template for stx.plt plotting module usage."""
7
+
8
+ TEMPLATE = {
9
+ "name": "Plotting Module",
10
+ "description": "stx.plt usage for publication-ready figures with automatic CSV export",
11
+ "filename": "plot_script.py",
12
+ "priority": 2,
13
+ "content": '''#!/usr/bin/env python3
14
+ # -*- coding: utf-8 -*-
15
+ # Timestamp: {timestamp}
16
+ # File: {filepath}
17
+
18
+ """
19
+ stx.plt - Publication-Ready Plotting
20
+ ====================================
21
+
22
+ stx.plt wraps matplotlib with:
23
+ - Automatic CSV export when saving figures (reproducibility)
24
+ - Pre-configured paper-quality styles
25
+ - Enhanced axis methods (set_xyt, plot_line, etc.)
26
+ - Color palettes (COLORS injection in @stx.session)
27
+
28
+ Usage Patterns
29
+ --------------
30
+ 1. Direct API: import scitex as stx; stx.plt.subplots()
31
+ 2. With @stx.session: plt is auto-injected with proper style
32
+ 3. CLI: scitex plt <recipe.yaml> (for FigRecipe specs)
33
+ 4. MCP: plt_plot, plt_compose, plt_reproduce tools
34
+ """
35
+
36
+ import scitex as stx
37
+
38
+ # ============================================================
39
+ # Pattern 1: Direct API Usage
40
+ # ============================================================
41
+
42
+ # Basic figure creation
43
+ fig, ax = stx.plt.subplots()
44
+ x = [1, 2, 3, 4, 5]
45
+ y = [2, 4, 1, 5, 3]
46
+ ax.plot(x, y, label="Data")
47
+ ax.set_xyt("X Axis", "Y Axis", "My Plot") # Enhanced: xlabel, ylabel, title
48
+ ax.legend()
49
+
50
+ # Save with auto CSV export (creates plot.png + plot.csv)
51
+ stx.io.save(fig, "plot.png")
52
+
53
+ # ============================================================
54
+ # Pattern 2: Multiple Subplots
55
+ # ============================================================
56
+
57
+ fig, axes = stx.plt.subplots(2, 2, figsize=(10, 8))
58
+
59
+ # Flatten for easier iteration
60
+ for idx, ax in enumerate(axes.flat):
61
+ ax.plot([1, 2, 3], [idx, idx*2, idx*3])
62
+ ax.set_xyt(f"X{{idx}}", f"Y{{idx}}", f"Panel {{idx}}")
63
+
64
+ fig.tight_layout()
65
+ stx.io.save(fig, "multipanel.png")
66
+
67
+ # ============================================================
68
+ # Pattern 3: With @stx.session (Recommended)
69
+ # ============================================================
70
+
71
+ @stx.session
72
+ def main(
73
+ n_points=100,
74
+ CONFIG=stx.INJECTED, # Session config
75
+ plt=stx.INJECTED, # Pre-configured matplotlib
76
+ COLORS=stx.INJECTED, # Color palette
77
+ rng=stx.INJECTED, # Random generator
78
+ logger=stx.INJECTED, # Logger
79
+ ):
80
+ """Example plotting with session management."""
81
+ import numpy as np
82
+
83
+ # Generate data
84
+ x = np.linspace(0, 10, n_points)
85
+ y1 = np.sin(x) + rng.normal(0, 0.1, n_points)
86
+ y2 = np.cos(x) + rng.normal(0, 0.1, n_points)
87
+
88
+ # Create figure using injected plt
89
+ fig, ax = plt.subplots()
90
+
91
+ # Use injected COLORS for consistent styling
92
+ ax.plot(x, y1, color=COLORS[0], label="sin(x)")
93
+ ax.plot(x, y2, color=COLORS[1], label="cos(x)")
94
+
95
+ # Enhanced axis methods
96
+ ax.set_xyt("Time (s)", "Amplitude", "Waveform Comparison")
97
+ ax.legend()
98
+
99
+ # Save to CONFIG.SDIR_OUT (auto CSV export)
100
+ stx.io.save(fig, CONFIG.SDIR_OUT / "waveforms.png")
101
+ logger.info(f"Saved figure to {{CONFIG.SDIR_OUT}}")
102
+
103
+ return 0
104
+
105
+ # ============================================================
106
+ # Pattern 4: Statistical Plots
107
+ # ============================================================
108
+
109
+ def statistical_plots():
110
+ """Common statistical visualization patterns."""
111
+ import numpy as np
112
+
113
+ fig, axes = stx.plt.subplots(1, 3, figsize=(12, 4))
114
+
115
+ # Box plot
116
+ data = [np.random.randn(100) + i for i in range(3)]
117
+ axes[0].boxplot(data)
118
+ axes[0].set_xyt("Group", "Value", "Box Plot")
119
+
120
+ # Histogram
121
+ axes[1].hist(np.random.randn(1000), bins=30, edgecolor='black')
122
+ axes[1].set_xyt("Value", "Count", "Histogram")
123
+
124
+ # Scatter with regression
125
+ x = np.random.randn(50)
126
+ y = 2*x + np.random.randn(50)*0.5
127
+ axes[2].scatter(x, y, alpha=0.6)
128
+ axes[2].set_xyt("X", "Y", "Scatter Plot")
129
+
130
+ fig.tight_layout()
131
+ stx.io.save(fig, "stats_plots.png")
132
+
133
+ # ============================================================
134
+ # Pattern 5: Heatmaps and Images
135
+ # ============================================================
136
+
137
+ def heatmap_example():
138
+ """Heatmap visualization pattern."""
139
+ import numpy as np
140
+
141
+ fig, ax = stx.plt.subplots()
142
+
143
+ # Create correlation matrix
144
+ data = np.random.randn(10, 10)
145
+ corr = np.corrcoef(data)
146
+
147
+ im = ax.imshow(corr, cmap='RdBu_r', vmin=-1, vmax=1)
148
+ ax.set_xyt("Feature", "Feature", "Correlation Matrix")
149
+ fig.colorbar(im, ax=ax, label="Correlation")
150
+
151
+ stx.io.save(fig, "heatmap.png")
152
+
153
+ # ============================================================
154
+ # Key Features Summary
155
+ # ============================================================
156
+
157
+ """
158
+ stx.plt Key Features:
159
+ ---------------------
160
+ 1. Enhanced Axis Methods:
161
+ - ax.set_xyt(xlabel, ylabel, title) # All in one call
162
+ - ax.plot_line(x, y, **kwargs) # With auto data tracking
163
+
164
+ 2. Auto CSV Export:
165
+ - stx.io.save(fig, "plot.png") # Creates plot.png + plot.csv
166
+ - CSV contains all plotted data for reproducibility
167
+
168
+ 3. Pre-configured Styles:
169
+ - Publication-quality fonts and sizes
170
+ - Consistent color palettes
171
+ - Grid and tick configurations
172
+
173
+ 4. Color Palettes (via COLORS injection):
174
+ - COLORS[0], COLORS[1], ... for consistent styling
175
+ - Colorblind-friendly by default
176
+
177
+ 5. Figure Recipes (advanced):
178
+ - YAML specifications for reproducible figures
179
+ - CLI: scitex plt recipe.yaml -o output.png
180
+ - MCP: plt_plot, plt_compose, plt_reproduce
181
+
182
+ CLI Commands:
183
+ -------------
184
+ scitex plt <recipe.yaml> # Render from recipe
185
+ scitex plt --help # Show all options
186
+
187
+ MCP Tools:
188
+ ----------
189
+ plt_plot # Create figure from specification
190
+ plt_compose # Combine multiple figures
191
+ plt_reproduce # Reproduce from saved recipe
192
+ plt_crop # Crop whitespace
193
+ """
194
+
195
+ if __name__ == "__main__":
196
+ main()
197
+ ''',
198
+ }
199
+
200
+ __all__ = ["TEMPLATE"]
201
+
202
+ # EOF
@@ -0,0 +1,267 @@
1
+ #!/usr/bin/env python3
2
+ # Timestamp: 2026-01-25
3
+ # File: src/scitex/template/_templates/scholar.py
4
+ # ----------------------------------------
5
+
6
+ """Template for stx.scholar literature management module usage."""
7
+
8
+ TEMPLATE = {
9
+ "name": "Scholar Module",
10
+ "description": "stx.scholar usage for literature management, BibTeX enrichment, and PDF downloads",
11
+ "filename": "scholar_script.py",
12
+ "priority": 4,
13
+ "content": '''#!/usr/bin/env python3
14
+ # -*- coding: utf-8 -*-
15
+ # Timestamp: {timestamp}
16
+ # File: {filepath}
17
+
18
+ """
19
+ stx.scholar - Literature Management
20
+ ===================================
21
+
22
+ stx.scholar provides:
23
+ - BibTeX enrichment (DOIs, abstracts, citations, impact factors)
24
+ - PDF downloading with institutional access support
25
+ - Paper search across multiple databases
26
+ - Project-based paper organization
27
+ - CrossRef local database (167M+ papers)
28
+
29
+ Usage Patterns
30
+ --------------
31
+ 1. CLI: scitex scholar <command> [options]
32
+ 2. MCP: scholar_* tools for Claude Code integration
33
+ 3. Python API: stx.scholar.* functions
34
+
35
+ Typical Workflow
36
+ ----------------
37
+ 1. Create project: scitex scholar project create myresearch
38
+ 2. Add papers from BibTeX: scitex scholar add --bibtex refs.bib --project myresearch
39
+ 3. Enrich metadata: scitex scholar enrich --project myresearch
40
+ 4. Download PDFs: scitex scholar fetch --project myresearch
41
+ 5. Search for more: scitex scholar search "machine learning EEG"
42
+ """
43
+
44
+ import scitex as stx
45
+
46
+ # ============================================================
47
+ # Pattern 1: CLI Usage (Recommended)
48
+ # ============================================================
49
+
50
+ """
51
+ CLI Commands:
52
+ -------------
53
+
54
+ # Project Management
55
+ scitex scholar project create myresearch # Create new project
56
+ scitex scholar project list # List all projects
57
+
58
+ # Add Papers
59
+ scitex scholar add --bibtex refs.bib --project myresearch
60
+ scitex scholar add --doi "10.1038/nature12373" --project myresearch
61
+
62
+ # Enrich BibTeX (add DOIs, abstracts, citations)
63
+ scitex scholar enrich --bibtex refs.bib --output enriched.bib
64
+ scitex scholar enrich --project myresearch
65
+
66
+ # Download PDFs
67
+ scitex scholar fetch --project myresearch
68
+ scitex scholar fetch --doi "10.1038/nature12373" --output ./pdfs/
69
+
70
+ # Search Databases
71
+ scitex scholar search "machine learning EEG" --limit 50
72
+ scitex scholar search "CRISPR" --source crossref --year-min 2020
73
+
74
+ # Check Library Status
75
+ scitex scholar status --project myresearch
76
+ """
77
+
78
+ # ============================================================
79
+ # Pattern 2: CrossRef Local Search (167M+ papers)
80
+ # ============================================================
81
+
82
+ """
83
+ CrossRef Local Database:
84
+ ------------------------
85
+ Fast full-text search across 167M+ academic papers.
86
+ Supports FTS5 query syntax: AND, OR, NOT, "exact phrases"
87
+
88
+ CLI:
89
+ ----
90
+ scitex scholar crossref search "neural network AND hippocampus"
91
+ scitex scholar crossref get 10.1038/nature12373
92
+ scitex scholar crossref citations 10.1038/nature12373
93
+
94
+ MCP Tools:
95
+ ----------
96
+ crossref_search(query, limit) # Search papers
97
+ crossref_get(doi) # Get metadata by DOI
98
+ crossref_citations(doi, direction) # Get citing/cited papers
99
+ """
100
+
101
+ # ============================================================
102
+ # Pattern 3: Paper Caching for Research Topics
103
+ # ============================================================
104
+
105
+ """
106
+ Paper Cache Workflow:
107
+ ---------------------
108
+ Build reusable collections for specific research topics.
109
+
110
+ # Create cache from search query
111
+ scitex scholar cache create epilepsy "epilepsy seizure prediction" --limit 1000
112
+
113
+ # Query cached papers
114
+ scitex scholar cache query epilepsy --year-min 2020 --limit 50
115
+
116
+ # Get top cited papers
117
+ scitex scholar cache top-cited epilepsy --n 20
118
+
119
+ # Export to formats
120
+ scitex scholar cache export epilepsy --format bibtex --output refs.bib
121
+ scitex scholar cache export epilepsy --format csv --output papers.csv
122
+ """
123
+
124
+ # ============================================================
125
+ # Pattern 4: Institutional Authentication
126
+ # ============================================================
127
+
128
+ """
129
+ Institutional Access (OpenAthens/Shibboleth):
130
+ ---------------------------------------------
131
+ For downloading papers requiring institutional credentials.
132
+
133
+ # Check authentication status
134
+ scitex scholar auth status
135
+
136
+ # Login via OpenAthens
137
+ scitex scholar auth login --method openathens
138
+
139
+ # Logout and clear session
140
+ scitex scholar auth logout
141
+ """
142
+
143
+ # ============================================================
144
+ # Pattern 5: Python API Usage
145
+ # ============================================================
146
+
147
+ def python_api_example():
148
+ """Direct Python API usage."""
149
+ from scitex.scholar import (
150
+ search_papers,
151
+ enrich_bibtex,
152
+ download_pdf,
153
+ parse_bibtex,
154
+ )
155
+
156
+ # Search for papers
157
+ results = search_papers(
158
+ query="machine learning EEG",
159
+ search_mode="crossref",
160
+ limit=20
161
+ )
162
+
163
+ # Parse BibTeX file
164
+ papers = parse_bibtex("references.bib")
165
+
166
+ # Enrich with metadata
167
+ enrich_bibtex(
168
+ bibtex_path="references.bib",
169
+ output_path="enriched.bib",
170
+ add_abstracts=True,
171
+ add_citations=True,
172
+ add_impact_factors=True
173
+ )
174
+
175
+ # Download a specific PDF
176
+ download_pdf(
177
+ doi="10.1038/nature12373",
178
+ output_dir="./pdfs/"
179
+ )
180
+
181
+ # ============================================================
182
+ # Pattern 6: With @stx.session (Research Workflow)
183
+ # ============================================================
184
+
185
+ @stx.session
186
+ def main(
187
+ topic="neural networks",
188
+ n_papers=50,
189
+ CONFIG=stx.INJECTED,
190
+ logger=stx.INJECTED,
191
+ ):
192
+ """Research literature workflow."""
193
+ from scitex.scholar import search_papers, enrich_bibtex
194
+
195
+ # 1. Search for papers
196
+ logger.info(f"Searching for papers on: {{topic}}")
197
+ results = search_papers(
198
+ query=topic,
199
+ search_mode="crossref",
200
+ limit=n_papers
201
+ )
202
+
203
+ # 2. Save search results
204
+ stx.io.save(results, CONFIG.SDIR_OUT / "search_results.json")
205
+
206
+ # 3. If BibTeX exists, enrich it
207
+ bibtex_path = CONFIG.SDIR_OUT / "references.bib"
208
+ if bibtex_path.exists():
209
+ enrich_bibtex(
210
+ bibtex_path=str(bibtex_path),
211
+ output_path=str(CONFIG.SDIR_OUT / "enriched.bib")
212
+ )
213
+ logger.info("BibTeX enriched with metadata")
214
+
215
+ logger.info(f"Found {{len(results)}} papers")
216
+ return 0
217
+
218
+ # ============================================================
219
+ # MCP Tools Reference
220
+ # ============================================================
221
+
222
+ """
223
+ MCP Tools for Claude Code:
224
+ --------------------------
225
+
226
+ Search & Discovery:
227
+ - scholar_search_papers(query, limit, search_mode)
228
+ - scholar_crossref_search(query, limit, year_min, year_max)
229
+ - scholar_crossref_get(doi)
230
+ - scholar_crossref_citations(doi, direction)
231
+
232
+ Library Management:
233
+ - scholar_create_project(project_name, description)
234
+ - scholar_list_projects()
235
+ - scholar_add_papers_to_project(project, dois, bibtex_path)
236
+ - scholar_get_library_status(project)
237
+
238
+ Enrichment & Download:
239
+ - scholar_enrich_bibtex(bibtex_path, add_abstracts, add_citations)
240
+ - scholar_fetch_papers(project, papers, async_mode)
241
+ - scholar_download_pdf(doi, output_dir)
242
+
243
+ BibTeX Operations:
244
+ - scholar_parse_bibtex(bibtex_path)
245
+ - scholar_resolve_dois(titles, bibtex_path)
246
+ - scholar_export_papers(output_path, format)
247
+
248
+ Authentication:
249
+ - scholar_authenticate(method, institution)
250
+ - scholar_check_auth_status(method)
251
+ - scholar_logout(method)
252
+
253
+ Cache Operations:
254
+ - cache_create(name, query, limit)
255
+ - cache_query(name, fields, year_min, year_max)
256
+ - cache_top_cited(name, n)
257
+ - cache_export(name, output_path, format)
258
+ """
259
+
260
+ if __name__ == "__main__":
261
+ main()
262
+ ''',
263
+ }
264
+
265
+ __all__ = ["TEMPLATE"]
266
+
267
+ # EOF
@@ -0,0 +1,130 @@
1
+ #!/usr/bin/env python3
2
+ """Session script template - full @stx.session with all injections."""
3
+
4
+ TEMPLATE = {
5
+ "name": "Session Script",
6
+ "description": "@stx.session decorated script with auto CLI, config injection, and output tracking",
7
+ "filename": "script.py",
8
+ "usage": """
9
+ Usage:
10
+ python script.py # Run with defaults
11
+ python script.py --kwarg1 value # Override parameter
12
+ python script.py --help # Show auto-generated help
13
+
14
+ Output Structure:
15
+ script_out/
16
+ ├── output.csv # stx.io.save() files go here (ROOT)
17
+ ├── figure.png
18
+ └── FINISHED_SUCCESS/<session_id>/ # Session metadata only
19
+ """,
20
+ "content": '''#!/usr/bin/env python3
21
+ # -*- coding: utf-8 -*-
22
+ # Timestamp: "{timestamp}"
23
+ # File: {filepath}
24
+
25
+ """
26
+ {docstring}
27
+
28
+ Usage
29
+ -----
30
+ $ python {filename} --help # Show auto-generated CLI help
31
+ $ python {filename} # Run with default parameters
32
+ $ python {filename} --kwarg1 value # Override parameters
33
+
34
+ Injected Global Variables
35
+ -------------------------
36
+ CONFIG : DotDict (access: CONFIG.key or CONFIG['key'])
37
+ Session configuration with paths and metadata.
38
+
39
+ Key Paths:
40
+ - CONFIG.ID : Session ID (e.g., '2025Y-01M-20D-10h30m00s_XyZ1')
41
+ - CONFIG.FILE : This script's absolute path
42
+ - CONFIG.SDIR_OUT : Output ROOT directory ({filename_stem}_out/)
43
+ USE THIS for stx.io.save() - files go here!
44
+ - CONFIG.SDIR_RUN : Session run directory (inside RUNNING/ or FINISHED_*)
45
+ Contains logs and CONFIG snapshots only
46
+ - CONFIG.PID : Process ID
47
+ - CONFIG.ARGS : Parsed CLI arguments as dict
48
+
49
+ YAML Config (from ./config/*.yaml):
50
+ - CONFIG.<FILENAME>.<key> : Values from config files
51
+
52
+ plt : module
53
+ matplotlib.pyplot configured for session
54
+
55
+ COLORS : DotDict
56
+ Color palette: COLORS.blue, COLORS.red, COLORS.green, etc.
57
+
58
+ rng : RandomStateManager
59
+ Reproducible random number generator (seeded)
60
+
61
+ logger : SciTeXLogger
62
+ Configured logger: logger.info(), logger.warning(), logger.error()
63
+
64
+ Output Directory Structure
65
+ --------------------------
66
+ {filename_stem}_out/ <- CONFIG.SDIR_OUT (save files here!)
67
+ ├── output.csv <- stx.io.save(df, "output.csv")
68
+ ├── figure.png <- stx.io.save(fig, "figure.png")
69
+ ├── figure.csv <- Auto-exported plot data
70
+ └── FINISHED_SUCCESS/
71
+ └── <session_id>/ <- CONFIG.SDIR_RUN (logs/configs)
72
+ ├── CONFIGS/
73
+ │ ├── CONFIG.pkl
74
+ │ └── CONFIG.yaml
75
+ └── logs/
76
+ ├── stdout.log
77
+ └── stderr.log
78
+ """
79
+
80
+ import numpy as np
81
+ import scitex as stx
82
+
83
+
84
+ @stx.session
85
+ def main(
86
+ # Uncomment and modify as needed:
87
+ # input_file, # Required argument -> CLI positional
88
+ # n_samples=100, # Optional argument -> CLI --n-samples
89
+ # threshold=0.05, # Optional argument -> CLI --threshold
90
+ # verbose=True, # Optional argument -> CLI --verbose
91
+ CONFIG=stx.INJECTED, # Auto-injected from ./config/*.yaml
92
+ plt=stx.INJECTED, # Pre-configured matplotlib
93
+ COLORS=stx.INJECTED, # Color palette
94
+ rng=stx.INJECTED, # Random number generator
95
+ logger=stx.INJECTED, # Session logger
96
+ ):
97
+ """
98
+ Script description shown in --help output.
99
+
100
+ This docstring becomes the CLI help message.
101
+ """
102
+ # Log session info
103
+ logger.info(f"Session ID: {{CONFIG.ID}}")
104
+ logger.info(f"Output dir: {{CONFIG.SDIR_OUT}}") # Where files are saved
105
+
106
+ # Generate example data
107
+ x = np.linspace(0, 10, 100)
108
+ y = np.sin(x)
109
+
110
+ # Create figure
111
+ fig, ax = plt.subplots()
112
+ ax.plot_line(x, y, color=COLORS.blue, label="sin(x)")
113
+ ax.set_xyt("X", "Y", "Example Figure")
114
+ ax.legend_()
115
+
116
+ # Save outputs to CONFIG.SDIR_OUT (automatic)
117
+ stx.io.save(fig, "figure.png") # -> {filename_stem}_out/figure.png
118
+ # stx.io.save(df, "results.csv") # -> {filename_stem}_out/results.csv
119
+
120
+ return 0 # Return 0 for success
121
+
122
+
123
+ if __name__ == "__main__":
124
+ main()
125
+
126
+ # EOF
127
+ ''',
128
+ }
129
+
130
+ # EOF
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env python3
2
+ """Minimal session script template."""
3
+
4
+ TEMPLATE = {
5
+ "name": "Minimal Session Script",
6
+ "description": "Minimal @stx.session script with essential injections only",
7
+ "filename": "script.py",
8
+ "usage": """
9
+ Usage:
10
+ python script.py
11
+ python script.py --help
12
+ """,
13
+ "content": '''#!/usr/bin/env python3
14
+ # -*- coding: utf-8 -*-
15
+ # Timestamp: "{timestamp}"
16
+ # File: {filepath}
17
+
18
+ """
19
+ {docstring}
20
+ """
21
+
22
+ import scitex as stx
23
+
24
+
25
+ @stx.session
26
+ def main(
27
+ CONFIG=stx.INJECTED,
28
+ logger=stx.INJECTED,
29
+ ):
30
+ """Script description for --help."""
31
+ logger.info(f"Session: {{CONFIG.ID}}")
32
+ logger.info(f"Output: {{CONFIG.SDIR_OUT}}")
33
+ return 0
34
+
35
+
36
+ if __name__ == "__main__":
37
+ main()
38
+
39
+ # EOF
40
+ ''',
41
+ }
42
+
43
+ # EOF