filter_map
- emmet.builders.utils.filter_map(fn, work, /, *args, work_keys=None, **kwargs)
Apply a function to each item in an iterable, yielding non-None results.
Lazily maps
fnoverwork, passing each item as the first argument along with any additional positional and keyword arguments. Results that areNoneare excluded.When
work_keysis provided, each item inworkis not passed as a positional argument. Instead, the specified keys are extracted from each item (via attribute access or dict lookup) and forwarded tofnas keyword arguments, merged with any extra**kwargs.- Return type:
Iterator[TypeVar(T)]- Parameters:
fn (Callable[[...], T])
work (Iterable[V])
args (Any)
work_keys (list[str] | None)
kwargs (Any)
- Args:
fn: The function to apply to each item in
work. work: The iterable of items to process. *args: Additional positional arguments to forward tofn. work_keys: If provided, a list of keys/attributes to extract fromeach item in
workand pass as keyword arguments tofn.**kwargs: Additional keyword arguments to forward to
fn.- Yields:
Non-
Noneresults from applyingfnto each item inwork.