Skip to content

Commit

Permalink
Evaluate blueice_anchors expression (#124)
Browse files Browse the repository at this point in the history
* Evaluate blueice_anchors expression

* Increase coverage

* Follow Robert's suggestion
  • Loading branch information
dachengx authored Jan 7, 2024
1 parent 234fdf8 commit ccc7271
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@ parameter_definition:
uncertainty: 'stats.uniform(loc=-2, scale=4)'
# relative_uncertainty: false
fittable: true
blueice_anchors:
- -2
- -1
- 0
- 1
- 2
blueice_anchors: 'np.arange(-2, 3)'
fit_limits:
- -2
- 2
Expand Down
18 changes: 17 additions & 1 deletion alea/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(
ptype: Optional[str] = None,
uncertainty: Optional[Union[float, str]] = None,
relative_uncertainty: Optional[bool] = None,
blueice_anchors: Optional[List] = None,
blueice_anchors: Optional[Union[list, str]] = None,
fit_limits: Optional[Tuple] = None,
parameter_interval_bounds: Optional[Tuple[float, float]] = None,
fit_guess: Optional[float] = None,
Expand Down Expand Up @@ -95,6 +95,22 @@ def uncertainty(self, value: Optional[Union[float, str]]) -> None:
)
self._uncertainty = value

@property
def blueice_anchors(self) -> Any:
"""Return the blueice_anchors of the parameter.
If the blueice_anchors is a string, it will be evaluated as a numpy or scipy function.
"""
if isinstance(self._blueice_anchors, str):
return evaluate_numpy_scipy_expression(self._blueice_anchors).tolist()
else:
return self._blueice_anchors

@blueice_anchors.setter
def blueice_anchors(self, value: Optional[Union[list, str]]) -> None:
self._blueice_anchors = value

@property
def fit_guess(self) -> Optional[float]:
"""Return the initial guess for fitting the parameter."""
Expand Down

0 comments on commit ccc7271

Please sign in to comment.