From bc8a28547e8e9adad68c237987af4e33c349cd51 Mon Sep 17 00:00:00 2001 From: rocky Date: Wed, 25 Dec 2024 08:41:05 -0500 Subject: [PATCH 1/7] Lint found in ListPlot-point checking branch --- mathics/eval/drawing/plot.py | 14 ++++++++------ test/helper.py | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/mathics/eval/drawing/plot.py b/mathics/eval/drawing/plot.py index 3d34424c7..c89a91d14 100644 --- a/mathics/eval/drawing/plot.py +++ b/mathics/eval/drawing/plot.py @@ -201,19 +201,21 @@ def eval_ListPlot( [xx for xx, yy in plot_groups], [xx for xx, yy in plot_groups], x_range ) plot_groups = [plot_groups] - elif all(isinstance(line, list) for line in plot_groups): - if not all(isinstance(line, list) for line in plot_groups): + elif all(isinstance(line, (list, tuple)) for line in plot_groups): + if not all(isinstance(line, (list, tuple)) for line in plot_groups): return # He have a list of plot groups if all( - isinstance(point, list) and len(point) == 2 - for plot_group in plot_groups + isinstance(point, (list, tuple)) and len(point) == 2 + for _ in plot_groups for point in plot_groups ): pass elif not is_discrete_plot and all( - not isinstance(point, list) for line in plot_groups for point in line + not isinstance(point, (list, tuple)) + for line in plot_groups + for point in line ): # FIXME: is this right? y_min = min(plot_groups)[0] @@ -229,7 +231,7 @@ def eval_ListPlot( # Split into plot segments plot_groups = [[plot_group] for plot_group in plot_groups] if isinstance(x_range, (list, tuple)): - x_min, m_max = x_range + x_min, x_max = x_range y_min, y_max = y_range for lidx, plot_group in enumerate(plot_groups): diff --git a/test/helper.py b/test/helper.py index 58ebc17f6..6e13f7982 100644 --- a/test/helper.py +++ b/test/helper.py @@ -38,7 +38,7 @@ def evaluate(str_expr: str): def check_evaluation( str_expr: Optional[str], str_expected: Optional[str] = None, - failure_message: str = "", + failure_message: Optional[str] = "", hold_expected: bool = False, to_string_expr: Optional[bool] = True, to_string_expected: bool = True, From a9792ffb18050a5ba2a1c864bc78ea997f978346 Mon Sep 17 00:00:00 2001 From: rocky Date: Wed, 25 Dec 2024 10:24:10 -0500 Subject: [PATCH 2/7] Preserve ListExpression --- mathics/core/expression.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mathics/core/expression.py b/mathics/core/expression.py index 927791f70..83e37bab4 100644 --- a/mathics/core/expression.py +++ b/mathics/core/expression.py @@ -1410,8 +1410,13 @@ def rules(): if not isinstance(result, EvalMixin): return result, False if result.sameQ(new): - new._timestamp_cache(evaluation) - return new, False + # Even though result and new may be the same, + # new can be a Expression[SymbolConstant: System`List...] + # while "result' might be ListExpression!? + # So make sure to use "result", not "new". + if isinstance(result, Expression): + result._timestamp_cache(evaluation) + return result, False else: return result, True From 84ddcb232b7e72c3dc8275dd6f679b75c9a113e4 Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 29 Dec 2024 17:30:54 -0500 Subject: [PATCH 3/7] Remove unused iteration --- mathics/eval/drawing/plot.py | 1 - mathics/packages/Combinatorica-repo | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/mathics/eval/drawing/plot.py b/mathics/eval/drawing/plot.py index c89a91d14..85ff3a02c 100644 --- a/mathics/eval/drawing/plot.py +++ b/mathics/eval/drawing/plot.py @@ -208,7 +208,6 @@ def eval_ListPlot( # He have a list of plot groups if all( isinstance(point, (list, tuple)) and len(point) == 2 - for _ in plot_groups for point in plot_groups ): pass diff --git a/mathics/packages/Combinatorica-repo b/mathics/packages/Combinatorica-repo index 5db6e0bf9..493613881 160000 --- a/mathics/packages/Combinatorica-repo +++ b/mathics/packages/Combinatorica-repo @@ -1 +1 @@ -Subproject commit 5db6e0bf925aaf989e84e07edcf902a7e3ed57c1 +Subproject commit 493613881a2928787ada0c75d80c26568f5712d1 From a15e8cf286b4fdd7bab0d5de7b96d2a2164eeba4 Mon Sep 17 00:00:00 2001 From: rocky Date: Wed, 25 Dec 2024 08:41:05 -0500 Subject: [PATCH 4/7] Lint found in ListPlot-point checking branch --- mathics/eval/drawing/plot.py | 14 ++++++++------ test/helper.py | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/mathics/eval/drawing/plot.py b/mathics/eval/drawing/plot.py index 3d34424c7..c89a91d14 100644 --- a/mathics/eval/drawing/plot.py +++ b/mathics/eval/drawing/plot.py @@ -201,19 +201,21 @@ def eval_ListPlot( [xx for xx, yy in plot_groups], [xx for xx, yy in plot_groups], x_range ) plot_groups = [plot_groups] - elif all(isinstance(line, list) for line in plot_groups): - if not all(isinstance(line, list) for line in plot_groups): + elif all(isinstance(line, (list, tuple)) for line in plot_groups): + if not all(isinstance(line, (list, tuple)) for line in plot_groups): return # He have a list of plot groups if all( - isinstance(point, list) and len(point) == 2 - for plot_group in plot_groups + isinstance(point, (list, tuple)) and len(point) == 2 + for _ in plot_groups for point in plot_groups ): pass elif not is_discrete_plot and all( - not isinstance(point, list) for line in plot_groups for point in line + not isinstance(point, (list, tuple)) + for line in plot_groups + for point in line ): # FIXME: is this right? y_min = min(plot_groups)[0] @@ -229,7 +231,7 @@ def eval_ListPlot( # Split into plot segments plot_groups = [[plot_group] for plot_group in plot_groups] if isinstance(x_range, (list, tuple)): - x_min, m_max = x_range + x_min, x_max = x_range y_min, y_max = y_range for lidx, plot_group in enumerate(plot_groups): diff --git a/test/helper.py b/test/helper.py index 58ebc17f6..6e13f7982 100644 --- a/test/helper.py +++ b/test/helper.py @@ -38,7 +38,7 @@ def evaluate(str_expr: str): def check_evaluation( str_expr: Optional[str], str_expected: Optional[str] = None, - failure_message: str = "", + failure_message: Optional[str] = "", hold_expected: bool = False, to_string_expr: Optional[bool] = True, to_string_expected: bool = True, From 8d797e7a1c328cc4b3ae521642543159f7fd2ee9 Mon Sep 17 00:00:00 2001 From: rocky Date: Wed, 25 Dec 2024 10:24:10 -0500 Subject: [PATCH 5/7] Preserve ListExpression --- mathics/core/expression.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mathics/core/expression.py b/mathics/core/expression.py index 550c0ab11..dfcfcabf2 100644 --- a/mathics/core/expression.py +++ b/mathics/core/expression.py @@ -1417,8 +1417,13 @@ def rules(): if not isinstance(result, EvalMixin): return result, False if result.sameQ(new): - new._timestamp_cache(evaluation) - return new, False + # Even though result and new may be the same, + # new can be a Expression[SymbolConstant: System`List...] + # while "result' might be ListExpression!? + # So make sure to use "result", not "new". + if isinstance(result, Expression): + result._timestamp_cache(evaluation) + return result, False else: return result, True From 702fbedff34ff1cba44f63a360f7b98499735c36 Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 29 Dec 2024 17:30:54 -0500 Subject: [PATCH 6/7] Remove unused iteration --- mathics/eval/drawing/plot.py | 1 - 1 file changed, 1 deletion(-) diff --git a/mathics/eval/drawing/plot.py b/mathics/eval/drawing/plot.py index c89a91d14..85ff3a02c 100644 --- a/mathics/eval/drawing/plot.py +++ b/mathics/eval/drawing/plot.py @@ -208,7 +208,6 @@ def eval_ListPlot( # He have a list of plot groups if all( isinstance(point, (list, tuple)) and len(point) == 2 - for _ in plot_groups for point in plot_groups ): pass From 70d53d6b2af234a13d72462f8d95d0b0f87895fa Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 29 Dec 2024 18:06:48 -0500 Subject: [PATCH 7/7] Try pulling Combinatorica explicitly --- .github/workflows/packages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index b9061c084..2addcaea2 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -38,6 +38,6 @@ jobs: cd mathics/packages/Combinatorica-repo # If Combinatorica repo changes, we may need the below altered # with a branch name, (not HEAD) for testing. - # git pull origin HEAD + git pull origin HEAD pip install -e .[dev] remake -x check