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

Uploaded Python 3

File details

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

File metadata

  • Download URL: scitex_gen-0.1.10.tar.gz
  • Upload date:
  • Size: 48.8 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.10.tar.gz
Algorithm Hash digest
SHA256 e2e276eb1d56464813a94fb17d713a0b27363d3b4decf16a9bee75abd23c0944
MD5 fdb524ce7b7275176239ca8aa141a008
BLAKE2b-256 dd1335fa006e396b3219a6a4895ec0e69d182eb14c55fac99c332178013f6102

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: scitex_gen-0.1.10-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.10-py3-none-any.whl
Algorithm Hash digest
SHA256 36a5f8f461828324a85ac4865cf2bfba36cf177154b6d2ee6c9580d76fcbe8cc
MD5 90165301a8e4699768c4cd0435794c52
BLAKE2b-256 bd083a4cf7e70112627f9b7b987cf0f66fe6ab614c2a7d1382a7aa54c5caad79

See more details on using hashes here.

Provenance

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