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
pip install scitex-str
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 |
Problem
Scientific Python code frequently needs LaTeX-style formatting for axis labels, colored terminal output for debugging, and structured string parsing for file paths and templates. These are scattered across ad-hoc helper functions in every project.
Solution
scitex-str provides a single package for text utilities commonly needed in scientific workflows:
- LaTeX formatting -- convert variable names to LaTeX style, with automatic fallback when LaTeX is unavailable
- Colored terminal output --
printcandcolor_textfor styled console messages - String parsing -- bidirectional
parse()to extract variables from path patterns - Plot text helpers -- format axis labels, titles, and tick labels for publication figures
- Numeric formatting -- factor out common digits, human-readable byte sizes
Installation
Requires Python >= 3.10.
pip install scitex-str
SciTeX users:
pip install scitexalready includes this. Useimport scitexthenscitex.str.
Quick Start
import scitex_str as ss
# LaTeX-style formatting
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
result = ss.parse("./data/Patient_23/Hour_12", "./data/Patient_{id}/Hour_{hour}")
# {'id': 23, 'hour': 12}
# Format plot text
ss.format_plot_text("amplitude_mv") # "Amplitude [mV]"
# Human-readable bytes
ss.readable_bytes(1_500_000) # "1.43 MB"
Part of SciTeX
scitex-str is part of SciTeX, a Python framework for scientific research automation.
| Module | Package | Role |
|---|---|---|
scitex.str |
scitex-str | Text processing utilities |
scitex.stats |
scitex-stats | Statistical testing |
scitex.io |
scitex-io | Universal file I/O |
scitex.plt |
figrecipe | Publication-ready figures |
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.4.tar.gz.
File metadata
- Download URL: scitex_str-0.1.4.tar.gz
- Upload date:
- Size: 42.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b60a9b80c23b47d007ccafc70bbd10f097dfa1615b5bd55eeae79bfd3c5e4fc
|
|
| MD5 |
558234d97a0ad9938071c18664728400
|
|
| BLAKE2b-256 |
8afadeb0c1166e8f80870ec480dd5b9162e199c7047fe20d82e0286da79e4458
|
Provenance
The following attestation bundles were made for scitex_str-0.1.4.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.4.tar.gz -
Subject digest:
5b60a9b80c23b47d007ccafc70bbd10f097dfa1615b5bd55eeae79bfd3c5e4fc - Sigstore transparency entry: 1396575662
- Sigstore integration time:
-
Permalink:
ywatanabe1989/scitex-str@fe65c13d9ccff3a95c0afd11ca978d4837f67166 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/ywatanabe1989
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@fe65c13d9ccff3a95c0afd11ca978d4837f67166 -
Trigger Event:
push
-
Statement type:
File details
Details for the file scitex_str-0.1.4-py3-none-any.whl.
File metadata
- Download URL: scitex_str-0.1.4-py3-none-any.whl
- Upload date:
- Size: 46.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae47169c0282d667e3406e241d1cbf3ff709527c7f42e819308c8ecf97063eca
|
|
| MD5 |
94c83ba09fb38037a81b85b0cc1da06b
|
|
| BLAKE2b-256 |
215229cf038e50e32b3af8f21209ffa9b0c033303736ed7ed854903622d039ab
|
Provenance
The following attestation bundles were made for scitex_str-0.1.4-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.4-py3-none-any.whl -
Subject digest:
ae47169c0282d667e3406e241d1cbf3ff709527c7f42e819308c8ecf97063eca - Sigstore transparency entry: 1396575664
- Sigstore integration time:
-
Permalink:
ywatanabe1989/scitex-str@fe65c13d9ccff3a95c0afd11ca978d4837f67166 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/ywatanabe1989
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@fe65c13d9ccff3a95c0afd11ca978d4837f67166 -
Trigger Event:
push
-
Statement type: