Skip to main content

Small linear-algebra helpers (distance, geometric median, cosine, nannorm) — standalone module from the SciTeX ecosystem

Project description

scitex-linalg

SciTeX

Small linear-algebra helpers — distances, NaN-aware norms, geometric median, vector projections.

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

PyPI Python Tests Coverage Docs License: AGPL v3


Installation

pip install scitex-linalg            # core (numpy/scipy/sympy)
pip install "scitex-linalg[torch]"   # + geometric_median (torch + geom-median)

Architecture

scitex_linalg/
├── _distance.py             ← euclidean_distance, cdist, edist, cosine
├── _misc.py                 ← nannorm, rebase_a_vec, three_line_lengths_to_coords
├── _geometric_median.py     ← torch geometric median (optional [torch] extra)
├── _vendor_decorators/      ← vendored numpy_fn / torch_fn / wrap (no scitex.* runtime dep)
└── _skills/                 ← agent-facing skill pages

Tiny single-purpose helpers. Pure numpy/scipy core; the geometric-median path opts into torch only when the [torch] extra is installed.

1 Interfaces

Python API
import scitex_linalg as sxl

sxl.euclidean_distance(u, v, axis=0)      # element-wise Euclidean distance
sxl.cdist(u, v)                           # pairwise distances
sxl.edist(u, v)                           # alias for cdist
sxl.cosine(v1, v2)                        # cosine similarity (NaN-safe)
sxl.nannorm(v, axis=-1)                   # NaN-aware vector norm
sxl.rebase_a_vec(v, v_base)               # project v onto v_base basis
sxl.three_line_lengths_to_coords(a, b, c) # triangle side lengths -> 2-D coords
sxl.geometric_median(xx, dim=-1)          # torch geometric median (requires [torch] extra)

Demo

flowchart LR
    A["u, v (np.ndarray)"] --> B["scitex_linalg.cdist"]
    B --> C["pairwise distance matrix"]
    A2["v with NaNs"] --> D["scitex_linalg.nannorm"]
    D --> E["NaN-safe vector norm"]
    A3["v, v_base"] --> F["scitex_linalg.rebase_a_vec"]
    F --> G["projected coords"]
    A4["xx (torch.Tensor)"] --> H["scitex_linalg.geometric_median"]
    H --> I["robust median point"]
>>> import numpy as np, scitex_linalg as sxl
>>> sxl.cosine(np.array([1, 0]), np.array([1, 1]))
0.7071...
>>> sxl.nannorm(np.array([3.0, np.nan, 4.0]))
5.0

Quick Start

import scitex_linalg as sxl

sxl.cdist(u, v)                # pairwise distances
sxl.cosine(v1, v2)             # cosine similarity (NaN-safe)
sxl.nannorm(v, axis=-1)        # NaN-aware norm
sxl.rebase_a_vec(v, v_base)    # project v onto v_base basis

Status

Standalone fork of scitex.linalg — intended to remain importable as scitex.linalg via the SciTeX umbrella package's bridge module. Decorators (numpy_fn, torch_fn, wrap) are vendored under _vendor_decorators/ to keep the package free of scitex.* runtime deps; when scitex-decorators is split out, those will be replaced with a direct dependency.

Part of SciTeX

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

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_linalg-0.1.4.tar.gz (26.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_linalg-0.1.4-py3-none-any.whl (29.2 kB view details)

Uploaded Python 3

File details

Details for the file scitex_linalg-0.1.4.tar.gz.

File metadata

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

File hashes

Hashes for scitex_linalg-0.1.4.tar.gz
Algorithm Hash digest
SHA256 d1eaf401e4a34d82c1a51351109613ea820985ce68bbcef25b15181d710f665d
MD5 5f5da683bc44a4867e55224d62803d19
BLAKE2b-256 8b80e9fb42d11c33531cb3d9c3291edefd0158eaee5ab86fea5dc14c004fb2a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for scitex_linalg-0.1.4.tar.gz:

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

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_linalg-0.1.4-py3-none-any.whl.

File metadata

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

File hashes

Hashes for scitex_linalg-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9a0b7f79929d7d4a80e8f356d1d34fe4f7efac5d0597e371fcedd99a882696b4
MD5 eb74e330fb3ac953af0c2351d3188059
BLAKE2b-256 7e5bb2f7da912be57fc2f72c7e00465bf15563afdc28537a3f352d26a55cf586

See more details on using hashes here.

Provenance

The following attestation bundles were made for scitex_linalg-0.1.4-py3-none-any.whl:

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

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