pyhs3.tensorutils.create_bounded_tensor¶
- pyhs3.tensorutils.create_bounded_tensor(name, domain, kind=<function scalar>)[source]¶
Creates a tensor variable with optional domain constraints.
- Parameters:
name (
str) – Name of the parameter.domain (tuple) – Tuple specifying (min, max) range. Use None for unbounded sides. For example: (0.0, None) for lower bound only, (None, 1.0) for upper bound only. If both bounds are None, returns an unbounded tensor.
kind (
Callable[...,TensorVar]) – pt.scalar for scalars, pt.vector for vectors (default: pt.scalar).
- Returns:
The tensor variable, clipped to domain if bounds exist.
- Return type:
Examples
>>> sigma = create_bounded_tensor("sigma", (0.0, None)) # sigma >= 0 (scalar) >>> fraction = create_bounded_tensor("fraction", (0.0, 1.0)) # 0 <= fraction <= 1 (scalar) >>> temperatures = create_bounded_tensor("temperatures", (None, 100.0), pt.vector) # vector <= 100 >>> unbounded = create_bounded_tensor("unbounded", (None, None)) # no bounds applied