neuralib.util.utils.keys_with_value
- neuralib.util.utils.keys_with_value(dy: dict[KT, Any | Collection[VT]], value: VT, to_item: Literal[False] = False) list[KT][source]
- neuralib.util.utils.keys_with_value(dy: dict[KT, VT | Collection[VT]], value: VT, to_item: Literal[True] = True) KT
Get keys from a dict that are associated with the value.
Supports value types: str, int, float (with tolerance), and any collection types.
- Parameters:
dy – The value to match against the dictionary values
value – The value to match against the dictionary value
to_item – List of item to item if unique
- Returns:
A list of keys whose values match the provided value