Conversation
test/builtin/test_patterns.py
Outdated
|
|
||
| def test_rule_repl_cond(): | ||
| for str_expr, str_expected, message in ( | ||
| ("f[x]/.(f[u_]->u^2/; u>3/; u>2)", "f[x]", "conditions are not evaluated"), |
There was a problem hiding this comment.
I just tried this on galatea and I don't see these results. Here is what I see:
>> f[x]/.(f[u_]->u^2/; u>3/; u>2)
= x ^ 2 /; x > 3 /; x > 2
>> f[1.]/.(f[u_]->u^2/; u>3/; u>2)
= 1. /; 1. > 3 /; 1. > 2
There was a problem hiding this comment.
You are right. When I tested it, I did it with delayed rules instead. There is something that I still am missing.
| def __init__(self, pattern, replace, delayed=True, system=False) -> None: | ||
| super(Rule, self).__init__(pattern, system=system) | ||
| self.replace = replace | ||
| self.delayed = delayed |
There was a problem hiding this comment.
This property helps to distinguish if the Rule comes from a Rule expression or a RuleDelayed expression, and it is needed to handle the different behavior observed in WMA. I do not see a reason for this different behavior, but maybe it is, and maybe there is a different behavior in other contexts.
|
Still, there is something that is not covered with this: consider the following code: In Mathics, the result is because the four lines sets over the same LHS pattern. On the other hand, the same code in WMA results in so rules with the same LHS but different RHS is also overwritten, except if the RHS is a |
Maybe ask on https://mathematica.stackexchange.com/ what is up here and more generally how to think about how WL groups assignment categories? |
|
Actually, I am looking there, but at existing related questions. |
2d37839 to
ed98034
Compare
…orm pat->Condition[expr_,cond]
ed98034 to
62cf433
Compare
|
Deprecated |
This PR fixed the bug described in #619 regarding the result of applying this kind of rule. The problem was not in the
applymethod itself but in thedo_replacemethod.