File size: 312 Bytes
b004d6f | 1 2 3 4 5 6 7 8 9 10 11 12 13 | """
Copyright (c) 2022 Ruilong Li, UC Berkeley.
"""
import collections
Rays = collections.namedtuple("Rays", ("origins", "viewdirs"))
def namedtuple_map(fn, tup):
"""Apply `fn` to each element of `tup` and cast to `tup`'s namedtuple."""
return type(tup)(*(None if x is None else fn(x) for x in tup))
|