mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-07 00:09:14 +08:00
Fix custom elements nested under @property (#3066)
* patch custom elements bug * Skip `cached_property` * fomrat * comment, type hint --------- Co-authored-by: Brent Yi <yibrenth@gmail.com>
This commit is contained in:
1 parent
d1fc2ee338
commit
c381fc818d
1 file changed
+5
-3
@@ -15,7 +15,8 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Any, List, Literal, Optional, Tuple, Union
|
from functools import cached_property
|
||||||
|
from typing import Any, List, Literal, Optional, Tuple, Type, Union
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import torch
|
import torch
|
||||||
@@ -109,7 +110,7 @@ def update_render_aabb(
|
|||||||
|
|
||||||
def parse_object(
|
def parse_object(
|
||||||
obj: Any,
|
obj: Any,
|
||||||
type_check,
|
type_check: Type[Any],
|
||||||
tree_stub: str,
|
tree_stub: str,
|
||||||
) -> List[Tuple[str, Any]]:
|
) -> List[Tuple[str, Any]]:
|
||||||
"""
|
"""
|
||||||
@@ -138,7 +139,8 @@ def parse_object(
|
|||||||
return []
|
return []
|
||||||
ret = []
|
ret = []
|
||||||
# get a list of the properties of the object, sorted by whether things are instances of type_check
|
# get a list of the properties of the object, sorted by whether things are instances of type_check
|
||||||
obj_props = [(k, v) for k, v in vars(obj).items()]
|
# we skip cached properties, which can be expensive to call `getattr()` on!
|
||||||
|
obj_props = [(k, getattr(obj, k)) for k in dir(obj) if not isinstance(getattr(type(obj), k, None), cached_property)]
|
||||||
for k, v in obj_props:
|
for k, v in obj_props:
|
||||||
if k[0] == "_":
|
if k[0] == "_":
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in new issue
Block a user