From 42f8a7294989e66e50f6302fb0f36cd4ac341bd4 Mon Sep 17 00:00:00 2001 From: mmatera Date: Mon, 26 Oct 2020 09:48:02 -0300 Subject: [PATCH 1/4] fix989 --- mathics/builtin/arithmetic.py | 4 ++++ mathics/core/expression.py | 2 +- mathics/core/parser/tokeniser.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mathics/builtin/arithmetic.py b/mathics/builtin/arithmetic.py index 1f16ed7691..65ee981dc0 100644 --- a/mathics/builtin/arithmetic.py +++ b/mathics/builtin/arithmetic.py @@ -658,7 +658,11 @@ class Divide(BinaryOperator): >> Pi / 4 = Pi / 4 + + Use 'N' or a decimal point to force numeric evaluation: + >> a /.5 + = 2. a >> Pi / 4.0 = 0.785398 >> 1 / 8 diff --git a/mathics/core/expression.py b/mathics/core/expression.py index 34c2febe3f..55bc32165f 100644 --- a/mathics/core/expression.py +++ b/mathics/core/expression.py @@ -379,7 +379,7 @@ def format_expr(expr): if head in formats: expr = expr.do_format(evaluation, form) elif (head != 'System`NumberForm' and not expr.is_atom() and - head != 'System`Graphics'): + head != 'System`Graphics'): new_leaves = [leaf.do_format(evaluation, form) for leaf in expr.leaves] expr = Expression( diff --git a/mathics/core/parser/tokeniser.py b/mathics/core/parser/tokeniser.py index 37d652a650..e282924067 100644 --- a/mathics/core/parser/tokeniser.py +++ b/mathics/core/parser/tokeniser.py @@ -122,7 +122,7 @@ ('RuleDelayed', r' (\:\>)|\uF51F '), ('UndirectedEdge', r' (\<\-\>)|\u29DF '), ('ReplaceRepeated', r' \/\/\. '), - ('ReplaceAll', r' \/\. '), + ('ReplaceAll', r' (\/\.)([^0-9]) '), ('Postfix', r' \/\/ '), From 08e9184afba44e68e7fe61f219c80940cf26a3ae Mon Sep 17 00:00:00 2001 From: mmatera Date: Mon, 26 Oct 2020 12:14:49 -0300 Subject: [PATCH 2/4] fixing ReplaceAll tokenizer with lookahead regexp --- mathics/core/expression.py | 2 +- mathics/core/parser/tokeniser.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mathics/core/expression.py b/mathics/core/expression.py index 55bc32165f..34c2febe3f 100644 --- a/mathics/core/expression.py +++ b/mathics/core/expression.py @@ -379,7 +379,7 @@ def format_expr(expr): if head in formats: expr = expr.do_format(evaluation, form) elif (head != 'System`NumberForm' and not expr.is_atom() and - head != 'System`Graphics'): + head != 'System`Graphics'): new_leaves = [leaf.do_format(evaluation, form) for leaf in expr.leaves] expr = Expression( diff --git a/mathics/core/parser/tokeniser.py b/mathics/core/parser/tokeniser.py index e282924067..5d05ae3414 100644 --- a/mathics/core/parser/tokeniser.py +++ b/mathics/core/parser/tokeniser.py @@ -122,7 +122,7 @@ ('RuleDelayed', r' (\:\>)|\uF51F '), ('UndirectedEdge', r' (\<\-\>)|\u29DF '), ('ReplaceRepeated', r' \/\/\. '), - ('ReplaceAll', r' (\/\.)([^0-9]) '), + ('ReplaceAll', r' (\/\.)(?=[^0-9]) '), ('Postfix', r' \/\/ '), From 2bd322069b50d5b106cd3110318b493d5c068953 Mon Sep 17 00:00:00 2001 From: Juan Mauricio Matera Date: Mon, 26 Oct 2020 19:46:17 -0300 Subject: [PATCH 3/4] Update arithmetic.py --- mathics/builtin/arithmetic.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/mathics/builtin/arithmetic.py b/mathics/builtin/arithmetic.py index 65ee981dc0..c7d56abb07 100644 --- a/mathics/builtin/arithmetic.py +++ b/mathics/builtin/arithmetic.py @@ -661,8 +661,6 @@ class Divide(BinaryOperator): Use 'N' or a decimal point to force numeric evaluation: - >> a /.5 - = 2. a >> Pi / 4.0 = 0.785398 >> 1 / 8 From ab74d89fdbe3b09e95bf27e5269562f41b7ae495 Mon Sep 17 00:00:00 2001 From: Juan Mauricio Matera Date: Mon, 26 Oct 2020 19:46:55 -0300 Subject: [PATCH 4/4] Update arithmetic.py --- mathics/builtin/arithmetic.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/mathics/builtin/arithmetic.py b/mathics/builtin/arithmetic.py index c7d56abb07..1f16ed7691 100644 --- a/mathics/builtin/arithmetic.py +++ b/mathics/builtin/arithmetic.py @@ -658,8 +658,6 @@ class Divide(BinaryOperator): >> Pi / 4 = Pi / 4 - - Use 'N' or a decimal point to force numeric evaluation: >> Pi / 4.0 = 0.785398