gluonts.util module#
- gluonts.util.copy_with(obj: gluonts.util.T, **kwargs) gluonts.util.T [source]#
Return copy of obj and update attributes of the copy using kwargs.
@dataclass class MyClass: value: int a = MyClass(1) b = copy_with(a, value=2) assert a.value == 1 assert b.value == 2
- gluonts.util.lazy_property(method)[source]#
Property that is lazily evaluated.
This is the same as:
@property @lru_cache(1) def my_property(self): ...
In addition to be more concise, lazy_property also works with mypy, since it poses to be just property when type checked.
This implementation follows the recipe from the functools documentation, and mimics functools.cached_property which was introduced in Python 3.8.