-
-
Notifications
You must be signed in to change notification settings - Fork 65
Fix Map #1692
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
Conversation
- `Apply` - `MapIndexed` - `MapThread`
A note on my absence and
|
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.
Pull request overview
This pull request fixes issue #1690 where Map does not automatically map a function over Association values, and adds operator forms for several functional programming functions.
Changes:
- Modified
Mapto detect when the expression is an Association and apply the function to values only (preserving keys in Rule elements) - Added operator form support for
Apply,Map,MapIndexed, andMapThreadusing transformation rules
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if is_association and level.has_form("Rule", 2): | ||
| return Expression( | ||
| SymbolRule, |
Copilot
AI
Feb 12, 2026
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 implementation only handles Rule but not RuleDelayed. Associations can contain both Rule and RuleDelayed elements (as seen in the codebase convention at mathics/builtin/list/associations.py:63, 91, 112, 153, 223, 324). The condition should be level.has_form(("Rule", "RuleDelayed"), 2) to handle both cases, and when creating the new expression, preserve the original head type using level.get_head() instead of always using SymbolRule.
| if is_association and level.has_form("Rule", 2): | |
| return Expression( | |
| SymbolRule, | |
| if is_association and level.has_form(("Rule", "RuleDelayed"), 2): | |
| return Expression( | |
| level.get_head(), |
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 was a good idea. We can include it in another round.
rocky
left a comment
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.
LGTM
No apology needed. This kind of thing happens a lot in open-source projects. We are grateful for any time you can devote here.
Recent work by @bdlucas1 on better-performing plotting has revealed a few things. See this discussion.
Again, no problem. This is perfectly understandable. Again, we are grateful for any time you can devote here. |
@Li-Xiang-Ideal, I also have been interested in making progress on that stuff for a much longer time, and the same happened to me, so let's keep faith.
If you want, I started this repo https://github.com/Mathics3/Mathics3-Module-sparse, to start building SparseArray functions as a separate module. I cannot promise to make many contributions there until July, but if at some point you are up for that, I can try to help you start implementing some basic |
CHANGES
Mapdoes not automatically map a function overAssociationvalues #1690 . NowMapautomatically maps function overAssociationvaluesApply,Map,MapIndexed,MapThread