Metadata-Version: 2.4
Name: scitex-str
Version: 0.1.7
Summary: Text processing utilities for scientific workflows — LaTeX formatting, colored output, string parsing, and plot text helpers
Project-URL: Homepage, https://github.com/ywatanabe1989/scitex-str
Project-URL: Documentation, https://scitex-str.readthedocs.io
Project-URL: Repository, https://github.com/ywatanabe1989/scitex-str.git
Project-URL: Issues, https://github.com/ywatanabe1989/scitex-str/issues
Author-email: Yusuke Watanabe <ywatanabe@scitex.ai>
License-Expression: AGPL-3.0-only
License-File: LICENSE
Keywords: color,formatting,latex,parsing,scientific,string,terminal,text
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Text Processing
Requires-Python: >=3.10
Requires-Dist: natsort
Requires-Dist: numpy
Requires-Dist: scitex
Requires-Dist: scitex-dict>=0.1.0
Provides-Extra: all
Provides-Extra: dev
Requires-Dist: numpy; extra == 'dev'
Requires-Dist: pre-commit>=3.5.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
Requires-Dist: pytest-xdist>=3.0.0; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Requires-Dist: scitex-dev>=0.7.0; extra == 'dev'
Provides-Extra: docs
Requires-Dist: myst-parser>=2.0; extra == 'docs'
Requires-Dist: sphinx-autodoc-typehints>=1.25; extra == 'docs'
Requires-Dist: sphinx-copybutton>=0.5; extra == 'docs'
Requires-Dist: sphinx-rtd-theme>=2.0; extra == 'docs'
Requires-Dist: sphinx>=7.0; extra == 'docs'
Description-Content-Type: text/markdown

# SciTeX Str (`scitex-str`)

<p align="center"><b>Text processing utilities for scientific workflows</b></p>

<!-- scitex-badges:start -->
[![PyPI](https://img.shields.io/pypi/v/scitex-str.svg)](https://pypi.org/project/scitex-str/)
[![Python](https://img.shields.io/pypi/pyversions/scitex-str.svg)](https://pypi.org/project/scitex-str/)
[![Tests](https://github.com/ywatanabe1989/scitex-str/actions/workflows/test.yml/badge.svg)](https://github.com/ywatanabe1989/scitex-str/actions/workflows/test.yml)
[![Install Test](https://github.com/ywatanabe1989/scitex-str/actions/workflows/install-test.yml/badge.svg)](https://github.com/ywatanabe1989/scitex-str/actions/workflows/install-test.yml)
[![Coverage](https://codecov.io/gh/ywatanabe1989/scitex-str/graph/badge.svg)](https://codecov.io/gh/ywatanabe1989/scitex-str)
[![Docs](https://readthedocs.org/projects/scitex-str/badge/?version=latest)](https://scitex-str.readthedocs.io/en/latest/)
[![License: AGPL v3](https://img.shields.io/badge/license-AGPL_v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)
<!-- scitex-badges:end -->

<p align="center">
  <code>pip install scitex-str</code>
</p>

---

## 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** -- `printc` and `color_text` for 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.

```bash
pip install scitex-str
```

> **SciTeX users**: `pip install scitex` already includes this. Use `import scitex` then `scitex.str`.

## Quick Start

```python
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**](https://scitex.ai), a Python framework for scientific research automation.

| Module | Package | Role |
|--------|---------|------|
| `scitex.str` | [scitex-str](https://github.com/ywatanabe1989/scitex-str) | Text processing utilities |
| `scitex.stats` | [scitex-stats](https://github.com/ywatanabe1989/scitex-stats) | Statistical testing |
| `scitex.io` | [scitex-io](https://github.com/ywatanabe1989/scitex-io) | Universal file I/O |
| `scitex.plt` | [figrecipe](https://github.com/ywatanabe1989/figrecipe) | Publication-ready figures |

---

<p align="center">
  <a href="https://scitex.ai" target="_blank">scitex.ai</a>
</p>

<!-- EOF -->
