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.3.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.3-py3-none-any.whl (29.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: scitex_linalg-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 d4f4b58abb0db9929eb6888225798522fa30d1844599b5593adf8fd98d3caea6
MD5 331c511dfd7812630aedcdb8fcf42b78
BLAKE2b-256 3c17c3ce50f32373cb54a1e39abd938a86d9e566933d986e0662da62f8ffaab6

See more details on using hashes here.

Provenance

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

Publisher: publish-pypi.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.3-py3-none-any.whl.

File metadata

  • Download URL: scitex_linalg-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 25717a1460ddc7e2b0a7b718658342d637eb7be2b8d60296e73de852a2de31fd
MD5 3f81b9f3ab87db494dbf5b347bdfb8e3
BLAKE2b-256 76e766f00ae9a3bc2620eaf067441c24830754eab77364a8bd3394b0111fa383

See more details on using hashes here.

Provenance

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

Publisher: publish-pypi.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