File size: 2,594 Bytes
5980447
1
2
{"repo": "mathics/Mathics", "pull_number": 863, "instance_id": "mathics__Mathics-863", "issue_numbers": "", "base_commit": "b32f7f844a4a9c62662da0a8dbab8fa72222e6c8", "patch": "diff --git a/mathics/builtin/graphs.py b/mathics/builtin/graphs.py\n--- a/mathics/builtin/graphs.py\n+++ b/mathics/builtin/graphs.py\n@@ -5,7 +5,7 @@\n Graphs\n \"\"\"\n \n-# uses GraphViz, if it's installed in your PATH (see pydotplus.graphviz.find_graphviz and http://www.graphviz.org).\n+# uses GraphViz, if it's installed in your PATH (see pydot.graphviz.find_graphviz and http://www.graphviz.org).\n \n from __future__ import unicode_literals\n from __future__ import absolute_import\n@@ -43,14 +43,13 @@ def _shell_layout(G):\n \n def _generic_layout(G, warn):\n     try:\n-        import pydotplus\n-\n-        if pydotplus.graphviz.find_graphviz():\n-            return nx.nx_pydot.graphviz_layout(G, prog='dot')\n+        import pydot\n     except ImportError:\n         pass\n+    else:\n+        return nx.nx_pydot.graphviz_layout(G, prog='dot')\n \n-    warn('Could not find pydotplus/dot; graph layout quality might be low.')\n+    warn('Could not find pydot; graph layout quality might be low.')\n     return nx.drawing.fruchterman_reingold_layout(G, pos=None, k=1.0)\n \n \n@@ -70,7 +69,10 @@ def _path_layout(G, root):\n \n         if not neighbors:\n             break\n-        v = next(neighbors) if isgenerator(neighbors) else neighbors[0]\n+        try:\n+            v = next(neighbors) if isgenerator(neighbors) else neighbors[0]\n+        except StopIteration:\n+            break\n         neighbors = G.neighbors(v)\n \n         if k == 0:\n@@ -162,7 +164,7 @@ def _pos_into_box(vertices, pos, min_box, max_box):\n \n         zx = (x0 + x1) / 2\n         zy = (y0 + y1) / 2\n-        s = 1.0 / max((x1 - x0) / dx, (y1 - y0) / dy)\n+        s = 1.0 / max(max(x1 - x0, 1) / dx, (max(y1 - y0, 1)) / dy)\n         for k, p in pos.items():\n             x, y = p\n             new_pos[k] = (cx + (x - zx) * s, cy + (y - zy) * s)\ndiff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -69,9 +69,10 @@\n     \"sympy>=1.6, < 1.7\",\n     \"django >= 1.8, < 1.12\",\n     \"mpmath>=1.1.0\",\n+    \"palettable\", # For bar charts, and portable, no-proprietary color palletes\n+    \"pydot\", # For graphs\n     \"python-dateutil\",\n     \"colorama\",\n-    \"palettable\",\n ]\n \n if not ((not is_PyPy and sys.version_info >= (3, 8)) or (is_PyPy and sys.version_info >= (3, 6))):\n", "test_patch": "", "problem_statement": "", "hints_text": "", "created_at": "2020-09-12T01:57:29Z"}