nshutils 0.22.0__tar.gz → 0.22.2__tar.gz

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.
Files changed (22) hide show
  1. {nshutils-0.22.0 → nshutils-0.22.2}/PKG-INFO +1 -1
  2. {nshutils-0.22.0 → nshutils-0.22.2}/pyproject.toml +1 -1
  3. {nshutils-0.22.0 → nshutils-0.22.2}/src/nshutils/actsave/_saver.py +3 -3
  4. {nshutils-0.22.0 → nshutils-0.22.2}/src/nshutils/lovely/_monkey_patch_all.py +11 -12
  5. {nshutils-0.22.0 → nshutils-0.22.2}/README.md +0 -0
  6. {nshutils-0.22.0 → nshutils-0.22.2}/src/nshutils/__init__.py +0 -0
  7. {nshutils-0.22.0 → nshutils-0.22.2}/src/nshutils/__init__.pyi +0 -0
  8. {nshutils-0.22.0 → nshutils-0.22.2}/src/nshutils/actsave/__init__.py +0 -0
  9. {nshutils-0.22.0 → nshutils-0.22.2}/src/nshutils/actsave/_loader.py +0 -0
  10. {nshutils-0.22.0 → nshutils-0.22.2}/src/nshutils/collections.py +0 -0
  11. {nshutils-0.22.0 → nshutils-0.22.2}/src/nshutils/display.py +0 -0
  12. {nshutils-0.22.0 → nshutils-0.22.2}/src/nshutils/logging.py +0 -0
  13. {nshutils-0.22.0 → nshutils-0.22.2}/src/nshutils/lovely/__init__.py +0 -0
  14. {nshutils-0.22.0 → nshutils-0.22.2}/src/nshutils/lovely/_base.py +0 -0
  15. {nshutils-0.22.0 → nshutils-0.22.2}/src/nshutils/lovely/config.py +0 -0
  16. {nshutils-0.22.0 → nshutils-0.22.2}/src/nshutils/lovely/jax_.py +0 -0
  17. {nshutils-0.22.0 → nshutils-0.22.2}/src/nshutils/lovely/numpy_.py +0 -0
  18. {nshutils-0.22.0 → nshutils-0.22.2}/src/nshutils/lovely/torch_.py +0 -0
  19. {nshutils-0.22.0 → nshutils-0.22.2}/src/nshutils/lovely/utils.py +0 -0
  20. {nshutils-0.22.0 → nshutils-0.22.2}/src/nshutils/snoop.py +0 -0
  21. {nshutils-0.22.0 → nshutils-0.22.2}/src/nshutils/typecheck.py +0 -0
  22. {nshutils-0.22.0 → nshutils-0.22.2}/src/nshutils/util.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: nshutils
3
- Version: 0.22.0
3
+ Version: 0.22.2
4
4
  Summary:
5
5
  Author: Nima Shoghi
6
6
  Author-email: nimashoghi@gmail.com
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "nshutils"
3
- version = "0.22.0"
3
+ version = "0.22.2"
4
4
  description = ""
5
5
  authors = [{ name = "Nima Shoghi", email = "nimashoghi@gmail.com" }]
6
6
  requires-python = ">=3.9,<4.0"
@@ -9,7 +9,7 @@ from dataclasses import dataclass
9
9
  from functools import wraps
10
10
  from logging import getLogger
11
11
  from pathlib import Path
12
- from typing import TYPE_CHECKING, Generic, Literal, cast, overload
12
+ from typing import TYPE_CHECKING, Generic, Literal, Union, cast, overload
13
13
 
14
14
  import numpy as np
15
15
  from typing_extensions import Never, ParamSpec, TypeAliasType, TypeVar, override
@@ -37,9 +37,9 @@ else:
37
37
  log = getLogger(__name__)
38
38
 
39
39
  Value = TypeAliasType(
40
- "Value", int | float | complex | bool | str | np.ndarray | Tensor | None
40
+ "Value", Union[int, float, complex, bool, str, np.ndarray, Tensor, None]
41
41
  )
42
- ValueOrLambda = TypeAliasType("ValueOrLambda", Value | Callable[..., Value])
42
+ ValueOrLambda = TypeAliasType("ValueOrLambda", Union[Value, Callable[..., Value]])
43
43
 
44
44
 
45
45
  def _torch_is_scripting() -> bool:
@@ -41,21 +41,20 @@ def monkey_patch(libraries: list[Library] | Literal["auto"] = "auto"):
41
41
 
42
42
  with contextlib.ExitStack() as stack:
43
43
  for library in libraries:
44
- match library:
45
- case "torch":
46
- from .torch_ import torch_monkey_patch
44
+ if library == "torch":
45
+ from .torch_ import torch_monkey_patch
47
46
 
48
- stack.enter_context(torch_monkey_patch())
49
- case "jax":
50
- from .jax_ import jax_monkey_patch
47
+ stack.enter_context(torch_monkey_patch())
48
+ elif library == "jax":
49
+ from .jax_ import jax_monkey_patch
51
50
 
52
- stack.enter_context(jax_monkey_patch())
53
- case "numpy":
54
- from .numpy_ import numpy_monkey_patch
51
+ stack.enter_context(jax_monkey_patch())
52
+ elif library == "numpy":
53
+ from .numpy_ import numpy_monkey_patch
55
54
 
56
- stack.enter_context(numpy_monkey_patch())
57
- case _:
58
- assert_never(library)
55
+ stack.enter_context(numpy_monkey_patch())
56
+ else:
57
+ assert_never(library)
59
58
 
60
59
  log.info(
61
60
  f"Monkey patched libraries: {', '.join(libraries)}. "
File without changes