shuinb's picture
Upload STB code utilities
b004d6f verified
Raw
History Blame Contribute Delete
312 Bytes
"""
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))