[sagemath] 01/01: Fix planarity 3 patch and re-enable it

Ximin Luo infinity0 at debian.org
Wed Nov 16 18:04:11 UTC 2016


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository sagemath.

commit af256be9ce8a2f895dde5a2346ad5e1bfc5834a3
Author: Ximin Luo <infinity0 at debian.org>
Date:   Wed Nov 16 19:03:16 2016 +0100

    Fix planarity 3 patch and re-enable it
---
 debian/control.in                        |   2 +-
 debian/patches/series                    |   2 +-
 debian/patches/version-planarity-3.patch | 104 +++++++++++++++++++++++--------
 debian/pruner/configure.ac               |   4 +-
 4 files changed, 80 insertions(+), 32 deletions(-)

diff --git a/debian/control.in b/debian/control.in
index eff685c..0c7032d 100644
--- a/debian/control.in
+++ b/debian/control.in
@@ -71,7 +71,7 @@ Build-Depends:
  libntl-dev (>= 9.9.1-2),
  libopenblas-dev (>= 0.2.19),
  libpari-dev (>= 2.9.0-1+sage1),
-# libplanarity-dev, this is version 3.0, we need 2.2
+ libplanarity-dev,
  libpng-dev,
  libppl-dev (>= 1:1.1),
  libpynac-dev (>= 0.2.6),
diff --git a/debian/patches/series b/debian/patches/series
index 652ddd8..0441790 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -24,7 +24,7 @@ version-cddlib-094h.patch
 version-glpk-4.60.patch
 version-pari-2.9-trac-21765.patch
 version-pari-2.9.patch
-#version-planarity-3.patch #breaks tests
+version-planarity-3.patch
 
 # due to Debian's inherent differences with upstream;
 # we're unlikely to forward these upstream
diff --git a/debian/patches/version-planarity-3.patch b/debian/patches/version-planarity-3.patch
index 5828230..6286ca9 100644
--- a/debian/patches/version-planarity-3.patch
+++ b/debian/patches/version-planarity-3.patch
@@ -1,67 +1,117 @@
 Description: Update Sage's planarity module to use API v3
- Sage uses 2.2.0 but the API difference from planarity 3 is not too bad.
- So let's try this instead of backporting planarity 2.2.0 to Debian.
+ Between v3 and v2, planarity upstream decided to switch from 0-based array
+ indexing to 1-based array indexing for the lulz. So funny, I really enjoyed
+ wasting several hours of my time.
 Author: Ximin Luo <infinity0 at debian.org>
-Bug: TODO
-Forwarded: TODO
+Bug: https://trac.sagemath.org/ticket/21774
 ---
 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
 --- a/sage/src/sage/graphs/planarity.pyx
 +++ b/sage/src/sage/graphs/planarity.pyx
-@@ -4,12 +4,12 @@
+@@ -3,13 +3,19 @@
+ """
  
  cdef extern from "planarity/graph.h":
-     ctypedef struct graphNode:
+-    ctypedef struct graphNode:
 -        int v
-+        int index
++    ctypedef struct vertexRec:
          int link[2]
-     ctypedef graphNode * graphNodeP
+-    ctypedef graphNode * graphNodeP
++        int index
++    ctypedef vertexRec * vertexRecP
++
++    ctypedef struct edgeRec:
++        int link[2]
++        int neighbor
++    ctypedef edgeRec * edgeRecP
  
      ctypedef struct BM_graph:
 -        graphNodeP G
-+        graphNodeP V
++        vertexRecP V
++        edgeRecP E
          int N
      ctypedef BM_graph * graphP
  
-@@ -136,10 +136,10 @@
+@@ -93,15 +99,16 @@
+             g._pos = { u: [0,0], v: [0,1] }
+         return (True, None) if kuratowski else True
+ 
+-    # create to and from mappings to relabel vertices to the set {0,...,n-1}
++    # create to and from mappings to relabel vertices to the set {1,...,n}
++    # (planarity 3 uses 1-based array indexing, with 0 representing NIL)
+     cdef int i
+     listto = g.vertices()
+     ffrom = {}
+     for vvv in listto:
+-        ffrom[vvv] = listto.index(vvv)
++        ffrom[vvv] = listto.index(vvv) + 1
+     to = {}
+     for i from 0 <= i < len(listto):
+-        to[i] = listto[i]
++        to[i + 1] = listto[i]
+     g.relabel(ffrom)
+ 
+     cdef graphP theGraph
+@@ -125,7 +132,7 @@
+     status = gp_Embed(theGraph, EMBEDFLAGS_PLANAR)
+     gp_SortVertices(theGraph)
+ 
+-    # use to and from mappings to relabel vertices back from the set {0,...,n-1}
++    # use to and from mappings to relabel vertices back from the set {1,...,n}
+     g.relabel(to)
+ 
+     if status == NOTOK:
+@@ -134,12 +141,12 @@
+         # Kuratowski subgraph isolator
+         g_dict = {}
          from sage.graphs.graph import Graph
-         for i from 0 <= i < theGraph.N:
+-        for i from 0 <= i < theGraph.N:
++        for i from 0 < i <= theGraph.N:
              linked_list = []
 -            j = theGraph.G[i].link[1]
-+            j = theGraph.V[i].link[1]
-             while j >= theGraph.N:
+-            while j >= theGraph.N:
 -                linked_list.append(to[theGraph.G[j].v])
 -                j = theGraph.G[j].link[1]
-+                linked_list.append(to[theGraph.V[j].index])
-+                j = theGraph.V[j].link[1]
++            j = theGraph.V[i].link[1]
++            while j:
++                linked_list.append(to[theGraph.E[j].neighbor])
++                j = theGraph.E[j].link[1]
              if len(linked_list) > 0:
                  g_dict[to[i]] = linked_list
          G = Graph(g_dict)
-@@ -155,10 +155,10 @@
+@@ -153,12 +160,12 @@
+             if set_embedding:
+                 emb_dict = {}
                  #for i in range(theGraph.N):
-                 for i from 0 <= i < theGraph.N:
+-                for i from 0 <= i < theGraph.N:
++                for i from 0 < i <= theGraph.N:
                      linked_list = []
 -                    j = theGraph.G[i].link[1]
-+                    j = theGraph.V[i].link[1]
-                     while j >= theGraph.N:
+-                    while j >= theGraph.N:
 -                        linked_list.append(to[theGraph.G[j].v])
 -                        j = theGraph.G[j].link[1]
-+                        linked_list.append(to[theGraph.V[j].index])
-+                        j = theGraph.V[j].link[1]
++                    j = theGraph.V[i].link[1]
++                    while j:
++                        linked_list.append(to[theGraph.E[j].neighbor])
++                        j = theGraph.E[j].link[1]
                      emb_dict[to[i]] = linked_list
                  g._embedding = emb_dict
              if set_pos:
-@@ -176,10 +176,10 @@
+@@ -174,12 +181,12 @@
+ 
+                 emb_dict = {}
                  #for i in range(theGraph.N):
-                 for i from 0 <= i < theGraph.N:
+-                for i from 0 <= i < theGraph.N:
++                for i from 0 < i <= theGraph.N:
                      linked_list = []
 -                    j = theGraph.G[i].link[0]
-+                    j = theGraph.V[i].link[0]
-                     while j >= theGraph.N:
+-                    while j >= theGraph.N:
 -                        linked_list.append(to[theGraph.G[j].v])
 -                        j = theGraph.G[j].link[0]
-+                        linked_list.append(to[theGraph.V[j].index])
-+                        j = theGraph.V[j].link[0]
++                    j = theGraph.V[i].link[0]
++                    while j:
++                        linked_list.append(to[theGraph.E[j].neighbor])
++                        j = theGraph.E[j].link[0]
                      emb_dict[to[i]] = linked_list
                  g._embedding = emb_dict
          gp_Free(&theGraph)
diff --git a/debian/pruner/configure.ac b/debian/pruner/configure.ac
index 7f1f388..8520c65 100644
--- a/debian/pruner/configure.ac
+++ b/debian/pruner/configure.ac
@@ -255,9 +255,7 @@ AC_SUBST(HAS_PKGCONF)
 HAS_PKGCONFIG="True"
 AC_SUBST(HAS_PKGCONFIG)
 
-# FIXME
-#AC_CHECK_HEADERS(planarity/planarity.h, HAS_PLANARITY="True", HAS_PLANARITY="False")
-HAS_PLANARITY="False"
+AC_CHECK_HEADERS(planarity/planarity.h, HAS_PLANARITY="True", HAS_PLANARITY="False")
 AC_SUBST(HAS_PLANARITY)
 
 # TODO(brial): brial 0.8.4.3+ has lost its pkg-config file. Hopefully this will

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/sagemath.git



More information about the debian-science-commits mailing list