Skip to content

Commit

Permalink
add distribution, boolean, and callable to Parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Mv77 committed Feb 22, 2024
1 parent 6a73c4f commit c12db93
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions HARK/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
----------
Expand All @@ -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)):
Expand Down

0 comments on commit c12db93

Please sign in to comment.