From c12db93656fc275d2c4dcb4a0c329b10c9583909 Mon Sep 17 00:00:00 2001 From: Mateo VG Date: Thu, 22 Feb 2024 18:46:51 -0500 Subject: [PATCH] add distribution, boolean, and callable to Parameters --- HARK/core.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/HARK/core.py b/HARK/core.py index 71a79e2a9..80389315d 100644 --- a/HARK/core.py +++ b/HARK/core.py @@ -14,7 +14,7 @@ from copy import copy, deepcopy from dataclasses import dataclass, field from time import time -from typing import Any, Dict, List, NewType, Optional, Union +from typing import Any, Dict, List, NewType, Optional, Union, Callable from warnings import warn import numpy as np @@ -103,11 +103,11 @@ def __infer_dims__( """ Infers the age-varying dimensions of a parameter. - If the parameter is a scalar, numpy array, or None, it is assumed to be - invariant over time. If the parameter is a list or tuple, it is assumed - to be varying over time. If the parameter is a list or tuple of length - greater than 1, the length of the list or tuple must match the - `_term_age` attribute of the Parameters object. + If the parameter is a scalar, numpy array, booleanm callable or None, + it is assumed to be invariant over time. If the parameter is a list or + tuple, it is assumed to be varying over time. If the parameter is a list + or tuple of length greater than 1, the length of the list or tuple must match + the `_term_age` attribute of the Parameters object. Parameters ---------- @@ -117,7 +117,9 @@ def __infer_dims__( value of parameter """ - if isinstance(value, (int, float, np.ndarray, type(None))): + if isinstance( + value, (int, float, np.ndarray, type(None), Distribution, bool, Callable) + ): self.__add_to_invariant__(key) return value if isinstance(value, (list, tuple)):