Nothing

Contents

Nothing#

class brainstate.util.Nothing[source]#

Filter that matches no objects.

This filter always returns False, effectively filtering out all objects. It’s useful for disabling selection or creating empty filter results.

Examples

>>> from brainstate.util.filter import Nothing
>>>
>>> # Create a filter that matches nothing
>>> none_filter = Nothing()
>>>
>>> # Always returns False
>>> none_filter([], 'any_object')
False
>>> none_filter(['some', 'path'], 42)
False
>>> none_filter([], None)
False
>>>
>>> # Useful for conditional filtering
>>> def get_params(model, include_frozen=False):
...     if include_frozen:
...         filter = Everything()
...     else:
...         filter = Nothing()  # Exclude all frozen params
...     # Apply filter to model parameters

See also

Everything

Filter that matches all objects

to_predicate

Convert False or None to Nothing filter

Notes

This filter is equivalent to using to_predicate(False) or to_predicate(None).