profiles.density.CoredNFWDensityProfile.substitute_expression#

CoredNFWDensityProfile.substitute_expression(expression: Any) Any#

Replace symbolic parameters with numerical values in an expression.

This method takes a symbolic expression that may include parameter symbols and substitutes them with the numerical values assigned at instantiation.

Parameters:

expression (str or Expr) – The symbolic expression to substitute parameter values into.

Returns:

The expression with parameters replaced by their numeric values.

Return type:

Expr

Notes

  • Only parameters defined in self.__parameters__ are substituted.

  • If an expression does not contain any parameters, it remains unchanged.

  • This method is useful for obtaining instance-specific symbolic representations.

Example

from sympy import Symbol

expr = Symbol("a") * Symbol("x")
coords = MyCoordinateSystem(a=3)
print(coords.substitute_expression(expr))
3 * x