Skip to content

Commit 4f3f190

Browse files
committed
Production audit: add __all__ exports, LICENSE file, minor cleanups
- Add __all__ to numpy.py, jax.py, torch.py, claw.py for explicit API surface - Add MIT LICENSE file to repo root - Fix _fail_obj type hint: object → object | None (_array_types.py) - Remove empty TestJaxBackend stub class (test_tree.py)
1 parent 4d1bf7d commit 4f3f190

File tree

7 files changed

+211
-5
lines changed

7 files changed

+211
-5
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 acecchini
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

src/shapix/_array_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class _ShapeChecker:
5656
def __init__(self, dtype_spec: DtypeSpec, shape_spec: tuple[DimSpec, ...]) -> None:
5757
self._dtype_spec = dtype_spec
5858
self._shape_spec = shape_spec
59-
self._fail_obj: object = None
59+
self._fail_obj: object | None = None
6060

6161
# Pre-compute repr for beartype error messages
6262
dims = ", ".join(repr(d) for d in shape_spec)

src/shapix/claw.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
from __future__ import annotations
1717

1818
from beartype import BeartypeConf
19+
20+
__all__ = ["shapix_this_package"]
1921
from beartype.claw import beartype_this_package as _beartype_this_package
2022

2123

src/shapix/jax.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,61 @@ def forward(x: F32[N, C, H, W]) -> BF16[N, C, H, W]: ...
1818
import numpy as np
1919
from jax import Array as JaxArray
2020

21+
__all__ = [
22+
# Array types
23+
"Bool",
24+
"I8",
25+
"I16",
26+
"I32",
27+
"I64",
28+
"U8",
29+
"U16",
30+
"U32",
31+
"U64",
32+
"F16",
33+
"F32",
34+
"F64",
35+
"BF16",
36+
"C64",
37+
"C128",
38+
"Int",
39+
"UInt",
40+
"Integer",
41+
"Float",
42+
"Real",
43+
"Complex",
44+
"Inexact",
45+
"Num",
46+
"Shaped",
47+
# Like types
48+
"BoolLk",
49+
"I8Like",
50+
"I16Like",
51+
"I32Like",
52+
"I64Like",
53+
"U8Like",
54+
"U16Like",
55+
"U32Like",
56+
"U64Like",
57+
"F16Like",
58+
"F32Like",
59+
"F64Like",
60+
"C64Like",
61+
"C128Like",
62+
"IntLk",
63+
"UIntLk",
64+
"IntegerLk",
65+
"FloatLk",
66+
"RealLk",
67+
"ComplexLk",
68+
"InexactLk",
69+
"NumLk",
70+
"ShapedLk",
71+
# Tree
72+
"Tree",
73+
"Structure",
74+
]
75+
2176
from ._array_types import make_array_type
2277
from ._tree import Structure as Structure
2378
from ._tree import _TreeFactory

src/shapix/numpy.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,86 @@ def conv(x: F32[N, C, H, W]) -> F32[N, C, H, W]: ...
2525
import numpy as np
2626
from beartype.vale import Is
2727

28+
__all__ = [
29+
# Array types
30+
"Bool",
31+
"I8",
32+
"I16",
33+
"I32",
34+
"I64",
35+
"U8",
36+
"U16",
37+
"U32",
38+
"U64",
39+
"F16",
40+
"F32",
41+
"F64",
42+
"C64",
43+
"C128",
44+
"Int",
45+
"UInt",
46+
"Integer",
47+
"Float",
48+
"Real",
49+
"Complex",
50+
"Inexact",
51+
"Num",
52+
"Shaped",
53+
# Scalar Like types
54+
"StringLike",
55+
"BoolLike",
56+
"Int8Like",
57+
"Int16Like",
58+
"Int32Like",
59+
"Int64Like",
60+
"UInt8Like",
61+
"UInt16Like",
62+
"UInt32Like",
63+
"UInt64Like",
64+
"Float16Like",
65+
"Float32Like",
66+
"Float64Like",
67+
"Complex64Like",
68+
"Complex128Like",
69+
"IntLike",
70+
"UIntLike",
71+
"IntegerLike",
72+
"FloatLike",
73+
"RealLike",
74+
"ComplexLike",
75+
"InexactLike",
76+
"NumLike",
77+
"ShapedLike",
78+
"Fraction",
79+
"Seed",
80+
"SeedLike",
81+
# Array Like types
82+
"ArrayLike",
83+
"BoolLk",
84+
"I8Like",
85+
"I16Like",
86+
"I32Like",
87+
"I64Like",
88+
"U8Like",
89+
"U16Like",
90+
"U32Like",
91+
"U64Like",
92+
"F16Like",
93+
"F32Like",
94+
"F64Like",
95+
"C64Like",
96+
"C128Like",
97+
"IntLk",
98+
"UIntLk",
99+
"IntegerLk",
100+
"FloatLk",
101+
"RealLk",
102+
"ComplexLk",
103+
"InexactLk",
104+
"NumLk",
105+
"ShapedLk",
106+
]
107+
28108
from ._array_types import make_array_type
29109
from ._dtypes import (
30110
BOOL,

src/shapix/torch.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,58 @@ def forward(x: F32[N, C, H, W]) -> F32[N, C, H, W]: ...
1818
import numpy as np
1919
from torch import Tensor
2020

21+
__all__ = [
22+
# Array types
23+
"Bool",
24+
"I8",
25+
"I16",
26+
"I32",
27+
"I64",
28+
"U8",
29+
"U16",
30+
"U32",
31+
"U64",
32+
"F16",
33+
"F32",
34+
"F64",
35+
"BF16",
36+
"C64",
37+
"C128",
38+
"Int",
39+
"UInt",
40+
"Integer",
41+
"Float",
42+
"Real",
43+
"Complex",
44+
"Inexact",
45+
"Num",
46+
"Shaped",
47+
# Like types
48+
"BoolLk",
49+
"I8Like",
50+
"I16Like",
51+
"I32Like",
52+
"I64Like",
53+
"U8Like",
54+
"U16Like",
55+
"U32Like",
56+
"U64Like",
57+
"F16Like",
58+
"F32Like",
59+
"F64Like",
60+
"C64Like",
61+
"C128Like",
62+
"IntLk",
63+
"UIntLk",
64+
"IntegerLk",
65+
"FloatLk",
66+
"RealLk",
67+
"ComplexLk",
68+
"InexactLk",
69+
"NumLk",
70+
"ShapedLk",
71+
]
72+
2173
from ._array_types import make_array_type
2274
from ._dtypes import (
2375
BFLOAT16,

tests/test_tree.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,10 +1264,6 @@ def f(x: Tree[F32[N, C]]) -> Tree[F32[N, C]]:
12641264
# =====================================================================
12651265

12661266

1267-
class TestJaxBackend:
1268-
"""Tests for jax-backed Tree (via shapix.jax.Tree)."""
1269-
1270-
12711267
# =====================================================================
12721268
# Repr and factory edge cases
12731269
# =====================================================================

0 commit comments

Comments
 (0)