pyrefly-shape-extensions 1.4.0.dev4__py3-none-any.whl → 1.5.0.dev1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pyrefly-shape-extensions
3
- Version: 1.4.0.dev4
3
+ Version: 1.5.0.dev1
4
4
  Summary: Shape typing primitives and DSL for Pyrefly tensor shape tracking
5
5
  Project-URL: homepage, https://pyrefly.org
6
6
  Project-URL: documentation, https://pyrefly.org/en/docs/
@@ -40,7 +40,7 @@ Runtime helpers for Pyrefly tensor shape annotations.
40
40
 
41
41
  This package provides the lightweight `shape_extensions` module used by
42
42
  Pyrefly's tensor shape stubs. It defines runtime no-op versions of the shape
43
- typing primitives so annotations such as `Tensor[B, T]`, `IntVar("B")`, and
43
+ typing primitives so annotations such as `Tensor[[B, T]]`, `IntVar("B")`, and
44
44
  `assert_shape(x.shape, (2, 3))` can be evaluated by Python while Pyrefly uses the
45
45
  corresponding stubs for static shape checking.
46
46
 
@@ -0,0 +1,8 @@
1
+ shape_extensions/__init__.py,sha256=4XNjrfvPqq3Wg4Jl1CEjJtxNWoZQSPJsRRNQC8jBuls,25472
2
+ shape_extensions/dsl.py,sha256=Yz8_nLzjS2D-cNNgUoR9r2kHCa-BZTgMsU25Z_QhKm0,3580
3
+ shape_extensions/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
4
+ shape_extensions/torchscript.py,sha256=Jk8Mv3dEEPGdkH6EIaHOzc11VvGwvq-o1eDELwWpUE8,12914
5
+ pyrefly_shape_extensions-1.5.0.dev1.dist-info/METADATA,sha256=0_lRPbOrqLSGKqGQgiB_mVh1B-wv_oy_sU5u8o3pwro,4601
6
+ pyrefly_shape_extensions-1.5.0.dev1.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
7
+ pyrefly_shape_extensions-1.5.0.dev1.dist-info/licenses/LICENSE,sha256=2m03A-0Ry-Qr0hLHJZV8mNojy_8ZmMBfpLPZdtGljpM,1088
8
+ pyrefly_shape_extensions-1.5.0.dev1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.32.4
2
+ Generator: hatchling 1.33.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -52,6 +52,7 @@ __all__ = [
52
52
  "RegularNestedList",
53
53
  "Shaped",
54
54
  "SymbolicArithExpr",
55
+ "TypeVar",
55
56
  "assert_shape",
56
57
  "assert_raises",
57
58
  "broadcast",
@@ -688,6 +689,51 @@ def broadcast(left: IntTuple, right: IntTuple) -> IntTuple:
688
689
  return gufunc_broadcast(spec, shapes)
689
690
 
690
691
 
692
+ class TypeVar:
693
+ """Runtime-safe legacy type variable for variadic shape dimensions.
694
+
695
+ This accepts the same arguments as ``typing.TypeVar`` on Python 3.12 and is
696
+ additionally iterable, so a shape variable can be unpacked as ``*S`` when
697
+ an annotation is evaluated at runtime.
698
+ """
699
+
700
+ __class__ = typing.TypeVar
701
+
702
+ def __init__(
703
+ self,
704
+ name: str,
705
+ *constraints,
706
+ bound=None,
707
+ covariant=False,
708
+ contravariant=False,
709
+ infer_variance=False,
710
+ ):
711
+ self.__name__ = name
712
+ self.__constraints__ = constraints
713
+ self.__bound__ = bound
714
+ self.__covariant__ = covariant
715
+ self.__contravariant__ = contravariant
716
+ self.__infer_variance__ = infer_variance
717
+
718
+ def __repr__(self):
719
+ return self.__name__
720
+
721
+ def __hash__(self):
722
+ return id(self)
723
+
724
+ def __eq__(self, other):
725
+ return self is other
726
+
727
+ def __iter__(self):
728
+ yield self
729
+
730
+ def __typing_subst__(self, arg):
731
+ return arg
732
+
733
+ def has_default(self):
734
+ return False
735
+
736
+
691
737
  class IntVar:
692
738
  """Symbolic variable with arithmetic support for tensor shape dimensions.
693
739
 
@@ -1,8 +0,0 @@
1
- shape_extensions/__init__.py,sha256=TWx-7WyN7tDMqznvJdLAzlHmdFIlvX_ucYVFEqvCNQs,24391
2
- shape_extensions/dsl.py,sha256=Yz8_nLzjS2D-cNNgUoR9r2kHCa-BZTgMsU25Z_QhKm0,3580
3
- shape_extensions/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
4
- shape_extensions/torchscript.py,sha256=Jk8Mv3dEEPGdkH6EIaHOzc11VvGwvq-o1eDELwWpUE8,12914
5
- pyrefly_shape_extensions-1.4.0.dev4.dist-info/METADATA,sha256=Bpz1yJdLJKAZFXjBxR2L80RZeYXXvPSFDEYopZbc9VA,4599
6
- pyrefly_shape_extensions-1.4.0.dev4.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
7
- pyrefly_shape_extensions-1.4.0.dev4.dist-info/licenses/LICENSE,sha256=2m03A-0Ry-Qr0hLHJZV8mNojy_8ZmMBfpLPZdtGljpM,1088
8
- pyrefly_shape_extensions-1.4.0.dev4.dist-info/RECORD,,