mirror of
https://github.com/wassname/jaxtyping.git
synced 2026-09-10 12:14:04 +08:00
Now provides PyTreeDef, and can detect PyTrees via issubclass(x, PyTree)
This commit is contained in:
@@ -1,13 +1,18 @@
|
||||
# Advanced features
|
||||
|
||||
## Abstract base classes
|
||||
## Creating your own dtypes
|
||||
|
||||
::: jaxtyping.AbstractDtype
|
||||
selection:
|
||||
members:
|
||||
false
|
||||
|
||||
::: jaxtyping.AbstractArray
|
||||
selection:
|
||||
members:
|
||||
false
|
||||
## Introspection
|
||||
|
||||
If you're writing your own type hint parser, then you may wish to detect if some Python object is a jaxtyping-provided type.
|
||||
|
||||
You can check for dtypes by doing `issubclass(x, AbstractDtype)`. For example, `issubclass(Float32, AbstractDtype)` will pass.
|
||||
|
||||
You can check for arrays by doing `issubclass(x, AbstractArray)`. Here, `AbstractArray` is the base class for all shape-and-dtype specified arrays, e.g. it's a base class for `Float32[Array, "foo"]`.
|
||||
|
||||
You can check for pytrees by doing `issubclass(x, PyTree)`. For example, `issubclass(PyTree[int], PyTree)` will pass.
|
||||
|
||||
Reference in New Issue
Block a user