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
├── _misc.py                 ← cosine, 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 euclidean_distance
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.5.tar.gz (28.1 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.5-py3-none-any.whl (31.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: scitex_linalg-0.1.5.tar.gz
  • Upload date:
  • Size: 28.1 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.5.tar.gz
Algorithm Hash digest
SHA256 36ac28da9dcc3d33d7bff24b3e8d9db777ec6381d3666a48be5940bced97dd0a
MD5 755890ce834fb41a79daacf135d099b0
BLAKE2b-256 8f7faf36edc7a985774a97dc7b41426c71195ae9769bc52a523f51b1c2a810ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for scitex_linalg-0.1.5.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.5-py3-none-any.whl.

File metadata

  • Download URL: scitex_linalg-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 31.0 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8e55a300148074aa5da906198739b4cfd0085b0d59b7752e9cadbd6633121af0
MD5 6e1c9810fa178f3ca13f9e35051c9aa3
BLAKE2b-256 61162907e885188086884f4bdd42ed71b2a3483d3bb53c896da538adf34df9fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for scitex_linalg-0.1.5-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