mirror of
https://github.com/wassname/jaxtyping.git
synced 2026-09-09 11:24:55 +08:00
update jaxtyped decorator (#44)
* update jaxtyped decorator * add newline character to pacify flake * add precomit hooks * add missing return statement * replace typing_extensions>=4.2.0 with typing_extensions * pin version range for typing_extensions * set min version of typing-extensions but not max * bump version number to 0.2.8
This commit is contained in:
@@ -67,4 +67,4 @@ from .import_hook import install_import_hook
|
||||
from .pytree_type import PyTree
|
||||
|
||||
|
||||
__version__ = "0.2.7"
|
||||
__version__ = "0.2.8"
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import functools as ft
|
||||
import inspect
|
||||
import threading
|
||||
|
||||
|
||||
@@ -44,4 +45,9 @@ class _Jaxtyped:
|
||||
|
||||
|
||||
def jaxtyped(fn):
|
||||
return ft.wraps(fn)(_Jaxtyped(fn))
|
||||
if inspect.isclass(fn): # allow decorators on class definitions
|
||||
init = jaxtyped(fn.__init__)
|
||||
fn.__init__ = init
|
||||
return fn
|
||||
else:
|
||||
return ft.wraps(fn)(_Jaxtyped(fn))
|
||||
|
||||
@@ -67,11 +67,14 @@ python_requires = "~=3.7"
|
||||
|
||||
# We use typeguard internally (in a fairly minimal way), but it's not required that
|
||||
# end users make the same choice.
|
||||
# For typing_extensions, we choose versions that match
|
||||
# https://github.com/explosion/confection/blob/main/setup.cfg#L33 used in colab
|
||||
|
||||
install_requires = [
|
||||
"jax>=0.3.4",
|
||||
"numpy>=1.20.0",
|
||||
"typeguard>=2.13.3",
|
||||
"typing_extensions>=4.2.0",
|
||||
"typing_extensions>=3.7.4.1",
|
||||
]
|
||||
|
||||
entry_points = dict(pytest11=["jaxtyping = jaxtyping.pytest_plugin"])
|
||||
|
||||
Reference in New Issue
Block a user