Describe the issue:
We have a component in a model that basically boils down to $e^{a+b\log(x)}$. $a$ and $b$ are scalars and $x$ is a vector whose elements are strictly positive, so that can be simplified to $e^ax^b$ to change the logs and exponentials over all the array elements into a single exponential and one elemwise power.
Even considering the case where x can be anything and $b$ is an odd integer, which makes the two options not return the same for x<=0, I think it would still be helpful to have a switch so all <=0 values are set to nan automatically and the rest are computed with the simplified expression.
I thought it would already be simplified but it looks like no rewrite happens
Reproducable code example:
import pytensor.tensor as pt
from pytensor.graph import rewrite_graph
a = pt.dscalar("a")
b = pt.dscalar("b")
x = pt.dvector("x")
g = pt.exp(a + b * pt.log(x))
g.dprint();
rewrite_graph(g).dprint();
PyTensor version information:
pytensor 2.31.6 installed from conda-forge
Describe the issue:
We have a component in a model that basically boils down to$e^{a+b\log(x)}$ . $a$ and $b$ are scalars and $x$ is a vector whose elements are strictly positive, so that can be simplified to $e^ax^b$ to change the logs and exponentials over all the array elements into a single exponential and one elemwise power.
Even considering the case where$b$ is an odd integer, which makes the two options not return the same for x<=0, I think it would still be helpful to have a switch so all <=0 values are set to nan automatically and the rest are computed with the simplified expression.
xcan be anything andI thought it would already be simplified but it looks like no rewrite happens
Reproducable code example:
PyTensor version information:
pytensor 2.31.6 installed from conda-forge