Skip to content

Commit

Permalink
Fix custom elements nested under @Property (nerfstudio-project#3066)
Browse files Browse the repository at this point in the history
* patch custom elements bug

* Skip `cached_property`

* fomrat

* comment, type hint

---------

Co-authored-by: Brent Yi <yibrenth@gmail.com>
  • Loading branch information
kerrj and brentyi authored Apr 11, 2024
1 parent d1fc2ee commit c381fc8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions nerfstudio/viewer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
from __future__ import annotations

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 torch
Expand Down Expand Up @@ -109,7 +110,7 @@ def update_render_aabb(

def parse_object(
obj: Any,
type_check,
type_check: Type[Any],
tree_stub: str,
) -> List[Tuple[str, Any]]:
"""
Expand Down Expand Up @@ -138,7 +139,8 @@ def add(ret: List[Tuple[str, Any]], ts: str, v: Any):
return []
ret = []
# 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:
if k[0] == "_":
continue
Expand Down

0 comments on commit c381fc8

Please sign in to comment.