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/
├── _cache.py             ← disk-backed @cache decorator
├── _norm.py              ← to_z, to_nanz (NaN-aware z-score)
├── _norm_cache.py        ← cached normalization variants
├── _to_even.py           ← to_even / to_odd integer rounding
├── _transpose.py         ← named-axis tensor transpose
├── _TimeStamper.py       ← elapsed-time logger
├── _xml2dict.py          ← XML → nested dict parser
├── _detect_environment.py← interactive / notebook / script detection
├── _SigMacro_*.py        ← legacy sigmaplot helpers (deprecated)
└── _skills/              ← agent-facing skill pages

Tiny single-purpose modules. Most are pure Python; to_z and the geometric-median variants opt into torch when available.

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.9.tar.gz (48.7 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.9-py3-none-any.whl (58.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: scitex_gen-0.1.9.tar.gz
  • Upload date:
  • Size: 48.7 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.9.tar.gz
Algorithm Hash digest
SHA256 dcb69d08312704f109c1a53b8a01fa197fbf7b1f6efeb568e193a6782f488a2a
MD5 f49e215603c9a1e7fe1262faea9177e1
BLAKE2b-256 b49c851864d148194ad7727633144b189ea8a7031eb5892c29eef5e55ba02c2f

See more details on using hashes here.

Provenance

The following attestation bundles were made for scitex_gen-0.1.9.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.9-py3-none-any.whl.

File metadata

  • Download URL: scitex_gen-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 58.1 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.9-py3-none-any.whl
Algorithm Hash digest
SHA256 c48c021cb1303bbb7ebcbae41da6433cd16c4542d1b110d3b2275c356920a743
MD5 a868257d8b1202d6e20d52c20772fd76
BLAKE2b-256 15b3c31b9f01c3ede0b1ec0d6c3fe8463cc3cc79618f163aa8c1edb83ede3dd4

See more details on using hashes here.

Provenance

The following attestation bundles were made for scitex_gen-0.1.9-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