Small linear-algebra helpers (distance, geometric median, cosine, nannorm) — standalone module from the SciTeX ecosystem
Project description
scitex-linalg
Small linear-algebra helpers — distances, NaN-aware norms, geometric median, vector projections.
Full Documentation · uv pip install scitex-linalg[all]
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
- The freedom to run your research anywhere — your machine, your terms.
- The freedom to study how every step works — from raw data to final manuscript.
- The freedom to redistribute your workflows, not just your papers.
- 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).
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1eaf401e4a34d82c1a51351109613ea820985ce68bbcef25b15181d710f665d
|
|
| MD5 |
5f5da683bc44a4867e55224d62803d19
|
|
| BLAKE2b-256 |
8b80e9fb42d11c33531cb3d9c3291edefd0158eaee5ab86fea5dc14c004fb2a0
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scitex_linalg-0.1.4.tar.gz -
Subject digest:
d1eaf401e4a34d82c1a51351109613ea820985ce68bbcef25b15181d710f665d - Sigstore transparency entry: 1571587211
- Sigstore integration time:
-
Permalink:
ywatanabe1989/scitex-linalg@ae8f8bd6ed0ad47c906bd5d56e4a9dd3db93c281 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/ywatanabe1989
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish-and-github-release-on-tag.yml@ae8f8bd6ed0ad47c906bd5d56e4a9dd3db93c281 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a0b7f79929d7d4a80e8f356d1d34fe4f7efac5d0597e371fcedd99a882696b4
|
|
| MD5 |
eb74e330fb3ac953af0c2351d3188059
|
|
| BLAKE2b-256 |
7e5bb2f7da912be57fc2f72c7e00465bf15563afdc28537a3f352d26a55cf586
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
scitex_linalg-0.1.4-py3-none-any.whl -
Subject digest:
9a0b7f79929d7d4a80e8f356d1d34fe4f7efac5d0597e371fcedd99a882696b4 - Sigstore transparency entry: 1571587236
- Sigstore integration time:
-
Permalink:
ywatanabe1989/scitex-linalg@ae8f8bd6ed0ad47c906bd5d56e4a9dd3db93c281 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/ywatanabe1989
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish-and-github-release-on-tag.yml@ae8f8bd6ed0ad47c906bd5d56e4a9dd3db93c281 -
Trigger Event:
push
-
Statement type: