mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-19 22:25:44 +08:00
Fixing documentation, moving IterableWrapper to pyrad/utils/misc, sorting imports
This commit is contained in:
1 parent
0422afc913
commit
482f7c9eea
2 files changed
+38
-26
No files matched your search
@@ -90,3 +90,28 @@ def get_hash_str_from_dict(dictionary: Dict[str, Any]) -> str:
|
||||
encoded = json.dumps(dictionary, sort_keys=True).encode()
|
||||
dhash.update(encoded)
|
||||
return dhash.hexdigest()
|
||||
|
||||
|
||||
class IterableWrapper:
|
||||
"""A helper that will allow an instance of a class to return multiple kinds of iterables bound to different functions of that class.
|
||||
|
||||
To use this, pass in the instance of the class you want to have multiple kinds of iterables for, and pass in a
|
||||
method belonging to that class that you want to be the __next__() method of the iterable. The resulting instantiated object will
|
||||
be an iterable that will use the passed in class method as the __next__() method.
|
||||
|
||||
Args:
|
||||
instance (object): instance class we are wrapping
|
||||
new_next (callable): function that will be called instead as the __next__()
|
||||
|
||||
|
||||
Attributes:
|
||||
instance (object): instance class we are wrapping
|
||||
new_next (callable): function that will be called instead as the __next__()
|
||||
"""
|
||||
|
||||
def __init__(self, instance: object, new_next: callable):
|
||||
self.instance = instance
|
||||
self.new_next = new_next
|
||||
|
||||
def __next__(self):
|
||||
return self.new_next(self.instance)
|
||||
Reference in new issue
Block a user