Skip to main content

General utilities (caching, env detection, normalization, mat→npy, xml→dict, TimeStamper, …) — standalone module from the SciTeX ecosystem

Project description

SciTeX Gen (scitex-gen)

SciTeX

General-purpose Python utilities for scientific workflows

Full Documentation · uv pip install scitex-gen[all]

pypi python docs

tests install-check cov


scitex-gen collects miscellaneous helpers that have been useful across many SciTeX projects: caching, normalization, environment detection, mat→npy conversion, xml→dict parsing, a TimeStamper, dimension wranglers, and more.

Problem and Solution

# Problem Solution
1 One-off utilities scatter across scripts -- every research repo grows its own to_even, xml2dict, TimeStamper, NaN-aware z-score Curated misc bag -- scitex_gen.cache / to_z / to_nanz / xml2dict / TimeStamper / transpose / to_even / to_odd collected in one importable place
2 Environment detection ad-hoc -- "am I in a notebook? a script? interactive?" answered three different ways across projects scitex_gen.detect_environment / is_notebook / is_script -- single canonical detector used across SciTeX peers
3 Legacy scitex.gen surface unstable -- helpers migrated to canonical peers (scitex_stats, scitex_os, scitex_str, ...) but old import paths still in use Backward-compatible re-exports + DeprecationWarning -- scitex_gen.check_host etc. still work, point to the new home, and warn at import time

Installation

Requires Python >= 3.10.

pip install scitex-gen

Configuration

Copy .env.example to .env (or source it from your shell) to override defaults such as SCITEX_DIR.

Architecture

scitex_gen/
├── _fs/                  ← filesystem helpers (symlink, src, title2path, print_config)
├── _introspect/          ← introspection, caching, DimHandler, list_packages, mat2py, xml2dict
├── _ipython/             ← IPython/Jupyter helpers (notebook detection, embed, paste, less)
├── _legacy/              ← backward-compat wrappers (TimeStamper, deprecated start/close)
├── _numeric/             ← math/numerics (norm, norm_cache, symlog, to_even, to_odd, to_rank, transpose)
├── _skills/              ← agent-facing skill pages
├── misc.py               ← connect_nums, float_linspace
├── path.py               ← placeholder (path management lives in scitex-path)
├── _type.py / _var_info.py   ← type annotations (optional, requires xarray)
└── _wrap.py              ← text wrapping utility

Tiny single-purpose modules organized by domain. Most are pure Python; to_z and the geometric-median variants opt into torch when available. Several functions are re-exported from peer packages (scitex-context, scitex-os, scitex-sh, etc.) for backward compatibility.

1 Interfaces

Python API
import scitex_gen

scitex_gen.cache(...)
scitex_gen.TimeStamper()
scitex_gen.detect_environment()
scitex_gen.xml2dict(...)
scitex_gen.to_z(...)
scitex_gen.to_even(7)     # 6
scitex_gen.to_odd(8)      # 7
scitex_gen.transpose(...)
scitex_gen.list_packages()

Full API reference

Demo

flowchart LR
    A["raw tensor / array"] --> B["scitex_gen.to_z"]
    B --> C["NaN-aware z-scored output"]
    D["xml string"] --> E["scitex_gen.xml2dict"]
    E --> F["nested dict"]
    G["expensive func"] --> H["@scitex_gen.cache"]
    H --> I["disk-backed result"]
>>> import scitex_gen as gen
>>> gen.to_even(7)
6
>>> gen.to_odd(8)
7
>>> ts = gen.TimeStamper(); ts("step1")  # logs elapsed

Quick Start

import scitex_gen as gen

gen.cache(...)
gen.TimeStamper()
gen.xml2dict(...)
gen.to_z(tensor)          # requires torch
gen.to_even(n)
gen.to_odd(n)
gen.transpose(...)

Status

Standalone fork of scitex.gen. The umbrella package's scitex.gen import path is preserved via a sys.modules-alias bridge.

Decoupling notes:

  • scitex.{decorators,str,os,introspect,session,context,sh,dict}scitex_* direct imports (peer packages).
  • scitex.torch.nanstd → optional via try/except with a torch-only fallback (only matters for _norm.to_z / to_nanz).
  • import scitex removed from _less.py (was unused in module body).
  • self-references in _norm_cache.py rewritten to scitex_gen.*.

Part of SciTeX

scitex-gen is part of SciTeX. Install via the umbrella with pip install scitex[gen] to use as scitex.gen (Python).

The SciTeX system follows the Four Freedoms for Research below, inspired by the Free Software Definition:

Four Freedoms for Research

  1. The freedom to run your research anywhere — your machine, your terms.
  2. The freedom to study how every step works — from raw data to final manuscript.
  3. The freedom to redistribute your workflows, not just your papers.
  4. 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 (see LICENSE).


SciTeX

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scitex_gen-0.1.11.tar.gz (50.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scitex_gen-0.1.11-py3-none-any.whl (60.5 kB view details)

Uploaded Python 3

File details

Details for the file scitex_gen-0.1.11.tar.gz.

File metadata

  • Download URL: scitex_gen-0.1.11.tar.gz
  • Upload date:
  • Size: 50.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for scitex_gen-0.1.11.tar.gz
Algorithm Hash digest
SHA256 c7f028086bc7726336a10a4222d46d85a0ce665edad226e9303a6702bf871cfe
MD5 01751523333a6bbad809be443ab3f272
BLAKE2b-256 ce58d69a16b5ecab2657ee3f000ea95ad8f53667e3964a617051bd548fe9f9d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for scitex_gen-0.1.11.tar.gz:

Publisher: pypi-publish-and-github-release-on-tag.yml on ywatanabe1989/scitex-gen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file scitex_gen-0.1.11-py3-none-any.whl.

File metadata

  • Download URL: scitex_gen-0.1.11-py3-none-any.whl
  • Upload date:
  • Size: 60.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for scitex_gen-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 ac8782f287e5dd03f86ee5ca2e218ee89ab69c9eaa449609ebb66aaf8415dac8
MD5 bbe2c9d0565aeb17105abcce9fcbf410
BLAKE2b-256 bedd9786d3cb4235ef00469c0ce412f6d14d5bd7ad013186336595dd7856380c

See more details on using hashes here.

Provenance

The following attestation bundles were made for scitex_gen-0.1.11-py3-none-any.whl:

Publisher: pypi-publish-and-github-release-on-tag.yml on ywatanabe1989/scitex-gen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page