Skip to content

Commit

Permalink
Added deprecation message
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-kidger committed Sep 12, 2023
1 parent a7d03e9 commit 4a991eb
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions equinox/nn/_stateful.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import types
from collections.abc import Callable
from typing import Any, Generic, TYPE_CHECKING, TypeVar, Union
from typing_extensions import ParamSpec
Expand Down Expand Up @@ -52,6 +53,15 @@ def __init__(self, init: _Value):
- `init`: The initial value for the state.
"""
if isinstance(init, types.FunctionType):
# Technically a function is valid here, since we could allow any pytree.
# In practice that's weird / kind of useless, so better to explicitly raise
# the deprecation error.
raise ValueError(
"As of Equinox v0.11.0, `eqx.nn.StateIndex` now accepts the value "
"of the initial state directly. (Not a function that creates the "
"initial state.)"
)
self.marker = object()
self.init = init

Expand Down

0 comments on commit 4a991eb

Please sign in to comment.