nshutils 0.11.1__py3-none-any.whl → 0.12.1__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.
nshutils/snoop.py
CHANGED
@@ -16,8 +16,8 @@ try:
|
|
16
16
|
import warnings
|
17
17
|
from contextlib import nullcontext
|
18
18
|
|
19
|
-
import pysnooper
|
20
|
-
import pysnooper.utils
|
19
|
+
import pysnooper # type: ignore
|
20
|
+
import pysnooper.utils # type: ignore
|
21
21
|
from pkg_resources import DistributionNotFound, get_distribution
|
22
22
|
|
23
23
|
try:
|
@@ -165,7 +165,7 @@ try:
|
|
165
165
|
+ self.tensor_format(x.QR)
|
166
166
|
+ ")"
|
167
167
|
)
|
168
|
-
|
168
|
+
raise ValueError("Unknown return_types encountered, open a bug report!")
|
169
169
|
|
170
170
|
def compute_repr(self, x):
|
171
171
|
orig_repr_func = pysnooper.utils.get_repr_function(x, self.orig_custom_repr)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: nshutils
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.12.1
|
4
4
|
Summary:
|
5
5
|
Author: Nima Shoghi
|
6
6
|
Author-email: nimashoghi@gmail.com
|
@@ -12,6 +12,8 @@ Classifier: Programming Language :: Python :: 3.12
|
|
12
12
|
Provides-Extra: extra
|
13
13
|
Requires-Dist: beartype
|
14
14
|
Requires-Dist: jaxtyping
|
15
|
+
Requires-Dist: lovely-numpy ; extra == "extra"
|
16
|
+
Requires-Dist: lovely-tensors ; extra == "extra"
|
15
17
|
Requires-Dist: numpy
|
16
18
|
Requires-Dist: pysnooper ; extra == "extra"
|
17
19
|
Requires-Dist: typing-extensions
|
@@ -35,7 +37,7 @@ pip install nshutils
|
|
35
37
|
|
36
38
|
### Typechecking
|
37
39
|
|
38
|
-
`nshutils` provides a simple way to typecheck your code using the `jaxtyping` library. Simply call `typecheck_this_module()` at the top of your module (i.e., in the root `__init__.py` file) to enable typechecking for the entire module:
|
40
|
+
`nshutils` provides a simple way to typecheck your code using the [`jaxtyping`](https://github.com/patrick-kidger/jaxtyping) library. Simply call `typecheck_this_module()` at the top of your module (i.e., in the root `__init__.py` file) to enable typechecking for the entire module:
|
39
41
|
|
40
42
|
```python
|
41
43
|
from nshutils.typecheck import typecheck_this_module
|
@@ -46,10 +48,10 @@ typecheck_this_module()
|
|
46
48
|
You can also use the `tassert` function to assert that a value is of a certain type:
|
47
49
|
|
48
50
|
```python
|
49
|
-
|
51
|
+
import nshutils.typecheck as tc
|
50
52
|
|
51
|
-
def my_function(x:
|
52
|
-
tassert(
|
53
|
+
def my_function(x: tc.Float[torch.Tensor, "bsz seq len"]) -> tc.Float[torch.Tensor, "bsz seq len"]:
|
54
|
+
tc.tassert(tc.Float[torch.Tensor, "bsz seq len"], x)
|
53
55
|
...
|
54
56
|
```
|
55
57
|
|
@@ -4,8 +4,8 @@ nshutils/actsave/_loader.py,sha256=fAhD32DrJa4onkYfcwc21YIeGEYzOSXCK_HVo9SZLgQ,4
|
|
4
4
|
nshutils/actsave/_saver.py,sha256=-uKMmMKjEErCa8pfLhAW4077GFcUjxr0Qq0PFAnbEOw,10254
|
5
5
|
nshutils/collections.py,sha256=EE_qLd-LrsX5lsyk9GSKh03Q8bhn9CHB3jiEeNj4uF4,5197
|
6
6
|
nshutils/logging.py,sha256=tL-6XvdvJEEr7bje9DSmUBpm6pnJS9XG_1fuw3U1eME,2573
|
7
|
-
nshutils/snoop.py,sha256=
|
7
|
+
nshutils/snoop.py,sha256=XhcFic6jbRP1EaBfcpcdtPdh-4kG6uHWKyZIRN4EPnM,7391
|
8
8
|
nshutils/typecheck.py,sha256=_KtfinRy9A0Dgq78kN5MGGrefvb6jn2tGY6svdLEBAs,4915
|
9
|
-
nshutils-0.
|
10
|
-
nshutils-0.
|
11
|
-
nshutils-0.
|
9
|
+
nshutils-0.12.1.dist-info/METADATA,sha256=siaT-_bO3xu877_P6g-kmJPo-EEVUuW7jEuCrFh-SRw,4034
|
10
|
+
nshutils-0.12.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
11
|
+
nshutils-0.12.1.dist-info/RECORD,,
|
File without changes
|