Skip to content

Commit

Permalink
Dropped dependency on numpy
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-kidger committed May 27, 2024
1 parent 49cf97e commit 102574f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion jaxtyping/_array_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,25 @@

import enum
import functools as ft
import importlib.util
import re
import sys
import types
import typing
from dataclasses import dataclass
from typing import Any, Literal, NoReturn, Optional, Union

import numpy as np

# Bit of a hack, but jaxtyping provides nicer error messages than typeguard. This means
# we sometimes want to use it as our runtime type checker everywhere, even in non-array
# use-cases, for which numpy is too heavy a dependency.
# Honestly we should probably consider factoring out part of jaxtyping into a separate
# package. (Specifically (a) the multi-argument checking and (b) the better error
# messages and (c) the import hook that places the checker on the bottom of the
# decorator stack.) And resist the urge to write our own runtime type-checker, I really
# don't want to have to keep that up-to-date with changes in the Python typing spec...
if importlib.util.find_spec("numpy") is not None:
import numpy as np

from ._errors import AnnotationError
from ._storage import (
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ classifiers = [
"Topic :: Scientific/Engineering :: Mathematics",
]
urls = {repository = "https://github.com/google/jaxtyping" }
dependencies = ["numpy>=1.20.0", "typeguard==2.13.3"]
dependencies = ["typeguard==2.13.3"]
entry-points = {pytest11 = {jaxtyping = "jaxtyping._pytest_plugin"}}

[build-system]
Expand Down

0 comments on commit 102574f

Please sign in to comment.