-
-
Notifications
You must be signed in to change notification settings - Fork 65
Handle RuleDelayed in Map over Association expressions #1694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
LGTM. Thanks for the generalization and clarification. |
|
btw now mathics-core/mathics/eval/functional/apply_fns_to_lists.py Lines 41 to 46 in a60d4f7
|
| # | ||
|
|
||
| if is_association and level.has_form(("Rule", "RuleDeyaled"), 2): | ||
| if is_association and level.has_form(("Rule", "RuleDelayed"), 2): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mistake wasn't caught in the existing tests. So, probably a test needs to be added here for the new features added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The question is, what should we test? For the full behavior, I have in mind a bunch of tests, that in the current implementation would not pass. The example in the comment is one of them.
To match with the WMA behavior, this method should be rewritten, and probably it would be also be interesting to define a specific class (like ListExpression) to store valid Association expressions. None of this would be too complicated, but right now I do not have the time to handle it.
What I could do is to list the tests here, or just add the tests to a pytest module, and mark them as xfail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The question is, what should we test?
So you are saying that nothing in this PR right now benefits a user? There is promise, though, that one day it will?
For the full behavior, I have in mind a bunch of tests, that in the current implementation would not pass. The example in the comment is one of them. To match with the WMA behavior, this method should be rewritten, and probably it would be also be interesting to define a specific class (like
ListExpression) to store validAssociationexpressions. None of this would be too complicated, but right now I do not have the time to handle it. What I could do is to list the tests here, or just add the tests to a pytest module, and mark them as xfail.
Yes, it is better to add xfail or commented-out tests now while the issue is fresh in your mind rather than do it later. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The question is, what should we test?
So you are saying that nothing in this PR right now benefits a user? There is promise, though, that one day it will?
For the full behavior, I have in mind a bunch of tests, that in the current implementation would not pass. The example in the comment is one of them. To match with the WMA behavior, this method should be rewritten, and probably it would be also be interesting to define a specific class (like
ListExpression) to store validAssociationexpressions. None of this would be too complicated, but right now I do not have the time to handle it. What I could do is to list the tests here, or just add the tests to a pytest module, and mark them as xfail.Yes, it is better to add xfail or commented-out tests now while the issue is fresh in your mind rather than do it later. Thanks.
This PR improves handling of some typical cases, but to cover the most general situation, we need to reimplement this.
77c564d to
0741f67
Compare
| "Map[F, Association[a->1, b:>Association[p->3,q->4]], {0}]", | ||
| None, | ||
| "F[Association[a->1, b:>Association[p->3, q->4]]]", | ||
| "Special behavior happends at the first level.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
happends -> occurs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
| "Map[F, Association[a->1, b:>Association[p->3,q->4]], {1}]", | ||
| None, | ||
| "Association[a->F[1], b:>F[Association[p->3, q->4]]]", | ||
| "Special behavior happends at the first level.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
happends -> occurs
| "Map[F, Association[a->1, b:>Q[p->3, q->4]], {2}]", | ||
| None, | ||
| "Association[a->1, b:>Q[F[p->3],F[q->4]]]", | ||
| "Special behavior happends at the first level.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
happends -> occurs
thanks for the observation! |
One slight change over #1692. Also, I add a comment about differences with WMA output in the case that the
Associationexpression does not have the formAssociation[__(Rule|RuleDelayed)].