Solution
Solution
Solution()One equality-solution branch: Expression assignments and validity conditions.
Index or iterate over the mapping to read assigned variables and their values. Use free_variables() for the family’s free coordinates and variables for all requested unknowns. All assignments hold simultaneously, subject to conditions(), which includes the parent set’s coverage guard.
Examples
from symbolica import Expression, S
x, y = S("x", "y")
branch = Expression.solve(x + y - 1, [x, y])[0]
branch[x] == 1 - y
True
dict(branch) == {x: 1-y}
True
branch.free_variables() == [y]
True
y in branch
FalseAttributes
| Name | Description |
|---|---|
domain |
The allowed domain of this branch’s unknowns. |
variables |
All requested unknowns in coordinate order, including free variables. |
domain
Solution.domain: SolveDomainThe allowed domain of this branch’s unknowns.
variables
Solution.variables: list[Expression]All requested unknowns in coordinate order, including free variables.
Methods
| Name | Description |
|---|---|
__contains__ |
Check whether a variable has an assignment in this branch. |
__getitem__ |
Retrieve an assigned Expression; raise KeyError for a free or absent variable. |
__iter__ |
|
__len__ |
Count assignments, excluding free variables. |
__repr__ |
|
__str__ |
|
_repr_html_ |
|
_repr_pretty_ |
Display the assignments in IPython. |
as_dict |
Return assigned variables mapped directly to Expressions |
codimension |
Return the number of unknowns minus the dimension, or None if unknown. |
conditions |
Return additional conditions that must hold for this branch to be valid. |
dimension |
Return the number of independent coordinates in this branch, or None if unknown. |
free_variables |
Return the unknowns that remain free within this branch. |
get |
Return an assigned Expression, or None for a free or absent variable. |
is_conditional |
Return whether this branch has additional validity conditions. |
is_point |
Return whether all unknowns have assigned expressions, possibly subject to conditions. |
items |
Return (variable, Expression) pairs, omitting free variables. |
keys |
Return the assigned variables in coordinate order; free variables are omitted. |
values |
Return the assigned Expressions in the same order as keys(). |
__contains__
Solution.__contains__(variable: Expression) -> boolCheck whether a variable has an assignment in this branch.
Parameters
variable(Expression) Variable to look up; free variables are not mapping keys.
__getitem__
Solution.__getitem__(variable: Expression) -> ExpressionRetrieve an assigned Expression; raise KeyError for a free or absent variable.
Parameters
variable(Expression) Variable whose assignment to retrieve.
__iter__
Solution.__iter__() -> Iterator[Expression]__len__
Solution.__len__() -> intCount assignments, excluding free variables.
__repr__
Solution.__repr__() -> str__str__
Solution.__str__() -> str_repr_html_
Solution._repr_html_() -> str_repr_pretty_
Solution._repr_pretty_(pretty: Any, cycle: bool) -> NoneDisplay the assignments in IPython.
Parameters
pretty(object) IPython’s pretty printer.cycle(bool) Whether this object is already being displayed.
as_dict
Solution.as_dict() -> dict[Expression, Expression]Return assigned variables mapped directly to Expressions.
Use free_variables() for free coordinates and conditions() for the restrictions under which these assignments are valid.
codimension
Solution.codimension() -> int | NoneReturn the number of unknowns minus the dimension, or None if unknown.
conditions
Solution.conditions() -> list[SolutionCondition]Return additional conditions that must hold for this branch to be valid.
dimension
Solution.dimension() -> int | NoneReturn the number of independent coordinates in this branch, or None if unknown.
free_variables
Solution.free_variables() -> list[Expression]Return the unknowns that remain free within this branch.
get
Solution.get(variable: Expression) -> Expression | NoneReturn an assigned Expression, or None for a free or absent variable.
Parameters
variable(Expression) Variable whose assignment to retrieve.branch[variable]raises KeyError when the variable is free or absent.
is_conditional
Solution.is_conditional() -> boolReturn whether this branch has additional validity conditions.
is_point
Solution.is_point() -> boolReturn whether all unknowns have assigned expressions, possibly subject to conditions.
items
Solution.items() -> list[tuple[Expression, Expression]]Return (variable, Expression) pairs, omitting free variables.
keys
Solution.keys() -> list[Expression]Return the assigned variables in coordinate order; free variables are omitted.
values
Solution.values() -> list[Expression]Return the assigned Expressions in the same order as keys().