FilterLiteral

Contents

FilterLiteral#

brainstate.typing.FilterLiteral#

Basic filter types that can be used to select parts of a PyTree.

Components#

type

Filter by type, e.g., float, jax.Array.

str

Filter by string matching in path keys.

Predicate

Custom function for complex filtering logic.

bool

Simple True/False filter.

Ellipsis

Wildcard filter that matches anything.

None

Filter that matches None values.

Examples

>>> # Filter by type
>>> float_filter: FilterLiteral = float
>>>
>>> # Filter by string pattern
>>> weight_filter: FilterLiteral = "weight"
>>>
>>> # Custom predicate filter
>>> matrix_filter: FilterLiteral = lambda path, x: hasattr(x, 'ndim') and x.ndim == 2