diff --git a/pts/core/component.py b/pts/core/component.py index 9888596..95ee54d 100644 --- a/pts/core/component.py +++ b/pts/core/component.py @@ -95,26 +95,22 @@ def validated(base_model=None): param.annotation if param.annotation != inspect.Parameter.empty else Any, - param.default - if param.default != inspect.Parameter.empty - else ..., + param.default if param.default != inspect.Parameter.empty else ..., ) for param in init_params.values() if param.name != "self" - and param.kind == inspect.Parameter.POSITIONAL_OR_KEYWORD + and param.kind == inspect.Parameter.POSITIONAL_OR_KEYWORD } if base_model is None: PydanticModel = create_model( - model_name=f"{init_clsnme}Model", + f"{init_clsnme}Model", __config__=BaseValidatedInitializerModel.Config, **init_fields, ) else: PydanticModel = create_model( - model_name=f"{init_clsnme}Model", - __base__=base_model, - **init_fields, + f"{init_clsnme}Model", __base__=base_model, **init_fields, ) def validated_repr(self) -> str: @@ -129,9 +125,7 @@ def validated(base_model=None): nmargs = { name: arg - for (name, param), arg in zip( - list(init_params.items()), [self] + args - ) + for (name, param), arg in zip(list(init_params.items()), [self] + args) if name != "self" } model = PydanticModel(**{**nmargs, **kwargs}) @@ -160,4 +154,4 @@ def validated(base_model=None): return init_wrapper - return validator \ No newline at end of file + return validator diff --git a/test/modules/test_distribution_output.py b/test/modules/test_distribution_output.py index 9a23f63..59d34b6 100644 --- a/test/modules/test_distribution_output.py +++ b/test/modules/test_distribution_output.py @@ -230,9 +230,9 @@ def test_lowrank_multivariate_normal() -> None: Sigma = cov_factor @ cov_factor.T + cov_diag distr = LowRankMultivariateNormal( - loc=torch.Tensor(loc), - cov_diag=torch.Tensor(np.diag(cov_diag)), - cov_factor=torch.Tensor(cov_factor), + loc=torch.Tensor(loc.copy()), + cov_diag=torch.Tensor(np.diag(cov_diag).copy()), + cov_factor=torch.Tensor(cov_factor.copy()), ) assert np.allclose(