SciTeX Str (scitex-str)
Text processing utilities for scientific workflows.
Full Documentation · uv pip install scitex-str[all]
Problem and Solution
| # | Problem | Solution |
|---|---|---|
| 1 | LaTeX labels crash matplotlib when TeX isn't installed — CI runners, laptops without MacTeX, Colab without !apt install texlive all fail |
safe_latex_render(s) — auto-detects LaTeX; falls back to mathtext then unicode silently |
| 2 | ANSI color codes + grep/parse sprinkled as ad-hoc re patterns — each script reinvents the wheel |
Grab-bag of helpers — printc, color_text, grep, parse, replace, mask_api, readable_bytes — boring but consistent across 33 packages |
Installation
Requires Python >= 3.10.
pip install scitex-str
Architecture
scitex_str/
├── _latex/ # LaTeX rendering with fallback
│ ├── _latex.py / _latex_fallback.py
│ └── ...
├── _ansi/ # ANSI color helpers
│ ├── _color_text.py / _remove_ansi.py
│ └── ...
├── _search/ # text search & template parse
│ ├── _grep.py / _parse.py / _search.py / _replace.py
│ └── ...
├── _plot/ # axis-label formatter
│ ├── _format_plot_text.py / _factor_out_digits.py
│ └── ...
├── _print/ # colored / debug console output
│ ├── _printc.py / _print_block.py / _print_debug.py
│ └── ...
├── _mask/ # sanitization
│ ├── _mask_api.py / _mask_api_key.py
│ └── ...
├── _case/ # case transforms
│ ├── _title_case.py / _decapitalize.py
│ └── ...
├── _readable_bytes.py # numeric formatting
├── _clean_path.py # path normalization
├── _squeeze_space.py # whitespace collapse
└── ... # ~20 boring helpers, one per file
flowchart LR
LX[LaTeX/mathtext<br/>fallback] --> A[to_latex_style<br/>safe_latex_render]
ANSI[ANSI tooling] --> B[printc / ct / remove_ansi]
Tmpl[Template parsing] --> C[parse / grep / search / replace]
Fmt[Numeric formatting] --> D[readable_bytes<br/>factor_out_digits]
Plot[Plot text] --> E[format_plot_text]
Sanit[Sanitization] --> F[mask_api_key]
Figure 1. Module layout. Each helper is a single-file leaf — boring on purpose, consistent across 33 ecosystem packages.
1 Interfaces
Python API
import scitex_str as ss
# LaTeX-style formatting (with safe fallback)
ss.to_latex_style("theta") # r"$\theta$"
ss.safe_to_latex_style("unknown") # "unknown" (no error)
# Colored terminal output
ss.printc("Success!", color="green")
ss.ct("Warning", color="yellow") # returns colored string
# Parse structured paths
ss.parse("./data/Patient_23/Hour_12",
"./data/Patient_{id}/Hour_{hour}") # {'id': 23, 'hour': 12}
# Plot text formatting
ss.format_plot_text("amplitude_mv") # "Amplitude [mV]"
# Numeric formatting
ss.readable_bytes(1_500_000) # "1.43 MB"
ss.factor_out_digits([1000, 2000, 3000])
# Misc
ss.grep(pattern, lines)
ss.search(...)
ss.replace(...)
ss.mask_api_key("sk-...")
ss.remove_ansi(text)
ss.squeeze_space("a b c") # "a b c"
ss.title_case("hello world")
ss.decapitalize("Hello")
Demo
import scitex_str as ss
# 1) LaTeX-safe label rendering — no crash if TeX missing
label = ss.safe_to_latex_style("theta") # "$\\theta$" or unicode fallback
# 2) Colored terminal status
ss.printc("[ok] tunnel established", color="green")
ss.printc("[warn] retry in 3s", color="yellow")
# 3) Parse a structured directory
ss.parse("./data/Patient_23/Hour_12",
"./data/Patient_{id}/Hour_{hour}") # → {'id': 23, 'hour': 12}
# 4) Human-readable byte size
ss.readable_bytes(1_500_000) # → "1.43 MB"
# 5) Mask credentials before logging
ss.mask_api_key("sk-abcdef1234567890") # → "sk-***7890"
flowchart LR
A[Raw value] --> B{kind?}
B -- bytes --> RB[readable_bytes]
B -- path --> P[parse]
B -- math --> L[safe_to_latex_style]
B -- secret --> M[mask_api_key]
B -- log line --> PC[printc]
RB --> O[Pretty output]
P --> O
L --> O
M --> O
PC --> O
style O fill:#27ae60,stroke:#2c3e50,color:#fff
Figure 2. Demo. Pick the helper by what you have, not by where it lives.
Part of SciTeX
scitex-str is part of SciTeX. Install via
the umbrella with pip install scitex[str] to use as
scitex.str (Python) or scitex str ... (CLI).
Four Freedoms for Research
- The freedom to run your research anywhere — your machine, your terms.
- The freedom to study how every step works — from raw data to final manuscript.
- The freedom to redistribute your workflows, not just your papers.
- The freedom to modify any module and share improvements with the community.
AGPL-3.0 — because we believe research infrastructure deserves the same freedoms as the software it runs on.
License
AGPL-3.0-only.
Metadata
Release files for scitex-str 0.1.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| scitex_str-0.1.14.tar.gz | 8.1 MB | Without provenance | Details for scitex_str-0.1.14.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| scitex_str-0.1.14-py3-none-any.whl | Python 3 | none | any | Details for scitex_str-0.1.14-py3-none-any.whl |
Total release size: 15.9 MB
Release files / scitex_str-0.1.14.tar.gz
| Download URL | scitex_str-0.1.14.tar.gz |
|---|---|
| Size | 8.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c15e511fd6522b642db12cc8cd596c63f9b824a97fc8198ae2ac9f2661e53559
|
|
BLAKE2b-256 checksum How to use checksums |
bd6c13d8e3ec8d599c18a16453808bbefe166da77e20a4c3d73ca8b10755d350
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Release files / scitex_str-0.1.14-py3-none-any.whl
| Download URL | scitex_str-0.1.14-py3-none-any.whl |
|---|---|
| Size | 7.8 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2868fda87e1151a4f0e904a447d2b5cc03baf0b1e3b6fe73eb8582633dd5701f
|
|
BLAKE2b-256 checksum How to use checksums |
e39f60929ac5bddc375e68434f443e10fd229e0b78aae2356007ffc1d679b6d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Security for scitex-str 0.1.14
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.