-
-
Notifications
You must be signed in to change notification settings - Fork 205
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
Fix ldots #993
Conversation
@mmatera Thanks for doing this. I'll look at Wednesday night. |
mathics/core/expression.py
Outdated
),"...",170)) | ||
else: | ||
return Expression("System`HoldForm",expr) | ||
|
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.
An interesting way to handle this.
I suspect there is a better way, but I don't know what it is.
And as you have said it doesn't fully address the problem of
In[1] = a...
Out[1] = a...
But this is an improvement.
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.
Let's go with this for now. It is an improvement even if it is not ideal or elegant.
We can always come back and revise as needed.
Again, thanks for doing.
I am assuming this gets us closer to handling more imports which would be super..
mathics/builtin/patterns.py
Outdated
@@ -206,6 +206,8 @@ def apply_levelspec(self, expr, rules, ls, evaluation, options): | |||
return result | |||
except InvalidLevelspecError: | |||
evaluation.message('General', 'level', ls) | |||
except PatternError as e: |
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.
There's no need to extract e
in here.
mathics/builtin/patterns.py
Outdated
return result | ||
result, applied = expr.apply_rules(rules, evaluation) | ||
return result | ||
except PatternError as e: |
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.
Same as before.
mathics/builtin/patterns.py
Outdated
@@ -309,8 +314,12 @@ class ReplaceRepeated(BinaryOperator): | |||
|
|||
def apply_list(self, expr, rules, evaluation): | |||
'ReplaceRepeated[expr_, rules_]' | |||
try: | |||
rules, ret = create_rules(rules, expr, 'ReplaceRepeated', evaluation) | |||
except PatternError as e: |
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.
Same as before.
mathics/builtin/patterns.py
Outdated
try: | ||
rules, ret = create_rules( | ||
rules, expr, 'ReplaceList', evaluation, extra_args=[max]) | ||
except PatternError as e: |
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.
Same as before.
mathics/builtin/patterns.py
Outdated
@@ -1114,7 +1127,8 @@ def init(self, expr, min=1): | |||
self.min = min | |||
if len(expr.leaves) == 2: | |||
leaf_1 = expr.leaves[1] | |||
if (leaf_1.has_form('List', 1, 2) and all(leaf.get_int_value() for leaf in leaf_1.leaves)): | |||
allnumbers = all(not (leaf.get_int_value() is None) for leaf in leaf_1.get_leaves()) | |||
if (leaf_1.has_form('List', 1, 2) and allnumbers ): |
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.
There's not need for the parenthesis in this condition.
mathics/builtin/patterns.py
Outdated
@@ -1114,7 +1127,8 @@ def init(self, expr, min=1): | |||
self.min = min | |||
if len(expr.leaves) == 2: | |||
leaf_1 = expr.leaves[1] | |||
if (leaf_1.has_form('List', 1, 2) and all(leaf.get_int_value() for leaf in leaf_1.leaves)): | |||
allnumbers = all(not (leaf.get_int_value() is None) for leaf in leaf_1.get_leaves()) |
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.
leaf.get_int_value() is not None
is more idiomatic than not (leaf.get_int_value() is None)
Thanks! |
This PR fixes the behavior of Repeated and RepeatedNull and introduce catch exceptions for wrong formatted patterns.
Import@"https://raw.githubusercontent.com/jkuczm/MathematicaCellsToTeX/master/NoInstall.m"
now still does not loads, but at least do not kill the interpreter...
@rocky please have a look at this.