Text processing utilities for scientific workflows — LaTeX formatting, colored output, string parsing, and plot text helpers
Project description
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/
├── _to_latex_style.py / _safe_to_latex_style.py # LaTeX rendering with fallback
├── _color_text.py / _printc.py # ANSI color helpers
├── _parse.py / _grep.py / _search.py / _replace.py # text search & template parse
├── _format_plot_text.py # axis-label formatter
├── _readable_bytes.py / _factor_out_digits.py # numeric formatting
├── _mask_api.py / _remove_ansi.py # sanitization
├── _squeeze_space.py / _title.py / _decapitalize.py# small string ops
└── ... # ~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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scitex_str-0.1.9.tar.gz.
File metadata
- Download URL: scitex_str-0.1.9.tar.gz
- Upload date:
- Size: 8.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e78a382a575fd7fb91279f77f58ea9cc2fb9e5b27dfe83e9cf17cbb9fc7fa9a4
|
|
| MD5 |
0a702ceb4c4beda01159cd6de7a0bdd5
|
|
| BLAKE2b-256 |
4aae5315ef1a79e1e36e7c4bf3f341094430e3a8dd4f7e360e296889050c37f7
|
Provenance
The following attestation bundles were made for scitex_str-0.1.9.tar.gz:
Publisher:
publish-pypi.yml on ywatanabe1989/scitex-str
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scitex_str-0.1.9.tar.gz -
Subject digest:
e78a382a575fd7fb91279f77f58ea9cc2fb9e5b27dfe83e9cf17cbb9fc7fa9a4 - Sigstore transparency entry: 1567359324
- Sigstore integration time:
-
Permalink:
ywatanabe1989/scitex-str@754c8300e1221f1d15c7d68d55d45dee74763cf6 -
Branch / Tag:
refs/tags/v0.1.9 - Owner: https://github.com/ywatanabe1989
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@754c8300e1221f1d15c7d68d55d45dee74763cf6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file scitex_str-0.1.9-py3-none-any.whl.
File metadata
- Download URL: scitex_str-0.1.9-py3-none-any.whl
- Upload date:
- Size: 8.4 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad13b9184f12131aafc95aba1bb68e42def15339628b7b4bf17016ed6f17d9bf
|
|
| MD5 |
0cc2d8597ba72881db8c7ce64c065418
|
|
| BLAKE2b-256 |
ef715afdc5b9cd12cf6f799fd5cc2109aa4eba0b089caca941670d531d8024da
|
Provenance
The following attestation bundles were made for scitex_str-0.1.9-py3-none-any.whl:
Publisher:
publish-pypi.yml on ywatanabe1989/scitex-str
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scitex_str-0.1.9-py3-none-any.whl -
Subject digest:
ad13b9184f12131aafc95aba1bb68e42def15339628b7b4bf17016ed6f17d9bf - Sigstore transparency entry: 1567359385
- Sigstore integration time:
-
Permalink:
ywatanabe1989/scitex-str@754c8300e1221f1d15c7d68d55d45dee74763cf6 -
Branch / Tag:
refs/tags/v0.1.9 - Owner: https://github.com/ywatanabe1989
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@754c8300e1221f1d15c7d68d55d45dee74763cf6 -
Trigger Event:
push
-
Statement type: