diff --git a/docs/api/array.md b/docs/api/array.md index 47dba50..d64aa48 100644 --- a/docs/api/array.md +++ b/docs/api/array.md @@ -45,19 +45,20 @@ As a special case: The dtype should be any one of (all imported from `jaxtyping`): - Any dtype at all: `Shaped` - - Boolean: `Bool` - - PRNG key: `Key` - - Any integer, unsigned integer, floating, or complex: `Num` - - Any floating or complex: `Inexact` - - Any floating point: `Float` - - Of particular precision: `BFloat16`, `Float16`, `Float32`, `Float64` - - Any complex: `Complex` - - Of particular precision: `Complex64`, `Complex128` - - Any integer or unsigned intger: `Integer` - - Any unsigned integer: `UInt` - - Of particular precision: `UInt8`, `UInt16`, `UInt32`, `UInt64` - - Any signed integer: `Int` - - Of particular precision: `Int8`, `Int16`, `Int32`, `Int64` + - Boolean: `Bool` + - PRNG key: `Key` + - Any integer, unsigned integer, floating, or complex: `Num` + - Any floating or complex: `Inexact` + - Any floating point: `Float` + - Of particular precision: `BFloat16`, `Float16`, `Float32`, `Float64` + - Any complex: `Complex` + - Of particular precision: `Complex64`, `Complex128` + - Any integer or unsigned intger: `Integer` + - Any unsigned integer: `UInt` + - Of particular precision: `UInt8`, `UInt16`, `UInt32`, `UInt64` + - Any signed integer: `Int` + - Of particular precision: `Int8`, `Int16`, `Int32`, `Int64` + - Any floating, integer, or unsigned integer: `Real`. Unless you really want to force a particular precision, then for most applications you should probably allow any floating-point, any integer, etc. That is, use ```python diff --git a/jaxtyping/__init__.py b/jaxtyping/__init__.py index c6cc612..e66d044 100644 --- a/jaxtyping/__init__.py +++ b/jaxtyping/__init__.py @@ -84,6 +84,7 @@ if typing.TYPE_CHECKING: Integer as Integer, Key as Key, Num as Num, + Real as Real, Shaped as Shaped, UInt as UInt, UInt8 as UInt8, @@ -110,6 +111,7 @@ else: Int64 as Int64, Integer as Integer, Num as Num, + Real as Real, Shaped as Shaped, UInt as UInt, UInt8 as UInt8, diff --git a/jaxtyping/_array_types.py b/jaxtyping/_array_types.py index c66f621..c31e74a 100644 --- a/jaxtyping/_array_types.py +++ b/jaxtyping/_array_types.py @@ -666,6 +666,7 @@ Integer = _make_dtype(uints + ints, "Integer") Float = _make_dtype(floats, "Float") Complex = _make_dtype(complexes, "Complex") Inexact = _make_dtype(floats + complexes, "Inexact") +Real = _make_dtype(floats + uints + ints, "Real") Num = _make_dtype(uints + ints + floats + complexes, "Num") Shaped = _make_dtype(_any_dtype, "Shaped") diff --git a/jaxtyping/_indirection.py b/jaxtyping/_indirection.py index a2378dc..33e6ea1 100644 --- a/jaxtyping/_indirection.py +++ b/jaxtyping/_indirection.py @@ -39,6 +39,7 @@ from typing import ( Annotated as Integer, # noqa: F401 Annotated as Key, # noqa: F401 Annotated as Num, # noqa: F401 + Annotated as Real, # noqa: F401 Annotated as Shaped, # noqa: F401 Annotated as UInt, # noqa: F401 Annotated as UInt8, # noqa: F401