Skip to content

Commit 3a20ea8

Browse files
committed
Backend-scoped Like fast path, tighten Dimension constructor, ShapedLike docs
- Scope Like fast-path trust per backend: JAX trusts (ndarray, jax.Array), Torch trusts (ndarray, Tensor). Foreign-backend arrays now fall through to the slow path where actual convertibility is verified via asarray. - Add trusted_types parameter to _ArrayLikeChecker, _ArrayLikeFactory, and make_array_like_type (default None preserves backward compat). - Reject non-str/non-int in Dimension.__new__ (float, None, object). - Reject +Scalar, +__, +~N in Dimension.__pos__. - Guard bare "+" and "+__" in _dim_spec broadcastable parsing. - Rename _ValueExpr to Value, remove TYPE_CHECKING branches for dims. - Tighten broadcastable docs in README and notebook. - Add ShapedLike runtime-vs-static approximation note to README.
1 parent 532627c commit 3a20ea8

File tree

10 files changed

+726
-98
lines changed

10 files changed

+726
-98
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def last_dim(x: F32[~__, C]) -> F32[~__, C]:
235235

236236
### Broadcastable dimensions
237237

238-
Apply `+` (unary plus) to any dimension to make it **broadcastable** — size 1 always matches, regardless of the bound value:
238+
Apply `+` (unary plus) to a named dimension, integer, or expression to make it **broadcastable** — size 1 always matches, regardless of the bound value:
239239

240240
```python
241241
from shapix import N, C
@@ -447,6 +447,8 @@ Dtype compatibility uses NumPy's `same_kind` casting rules by default: `int32` c
447447

448448
**Available:** `BoolLike`, `I8Like`, `I16Like`, `I32Like`, `I64Like`, `U8Like``U64Like`, `F16Like`, `F32Like`, `F64Like`, `F128Like`, `C64Like`, `C128Like`, `C256Like`, plus category aliases `IntLike`, `FloatLike`, `NumLike`, `ShapedLike`, etc.
449449

450+
> **Note:** `ShapedLike` has the same runtime-vs-static approximation as `Shaped`: runtime accepts any dtype, static alias narrows to bool | numeric.
451+
450452
Like types are also available in JAX and PyTorch backends:
451453

452454
```python

0 commit comments

Comments
 (0)