[pypy-svn] r18085 - in pypy/dist/pypy: annotation tool tool/algo tool/algo/test tool/math translator/backendopt
arigo at codespeak.net
arigo at codespeak.net
Sun Oct 2 18:53:02 CEST 2005
Author: arigo
Date: Sun Oct 2 18:52:51 2005
New Revision: 18085
Added:
pypy/dist/pypy/tool/algo/
- copied from r18084, pypy/dist/pypy/tool/math/
pypy/dist/pypy/tool/algo/test/autopath.py
- copied unchanged from r18079, pypy/dist/pypy/tool/test/autopath.py
pypy/dist/pypy/tool/algo/test/test_sparsemat.py (contents, props changed)
Removed:
pypy/dist/pypy/tool/math/
pypy/dist/pypy/tool/unionfind.py
pypy/dist/pypy/translator/backendopt/sparsemat.py
Modified:
pypy/dist/pypy/annotation/bookkeeper.py
pypy/dist/pypy/tool/algo/sparsemat.py
pypy/dist/pypy/tool/algo/test/test_graphlib.py
pypy/dist/pypy/translator/backendopt/inline.py
pypy/dist/pypy/translator/backendopt/malloc.py
pypy/dist/pypy/translator/backendopt/ssa.py
Log:
Introduced a directory 'tool/algo/' for the algorithmic modules. It's a good
place to regroup sparsemat, unionfind, and a new graph-manipulation module
doing cycle detection (graphs in the general sense, not flow graphs).
Modified: pypy/dist/pypy/annotation/bookkeeper.py
==============================================================================
--- pypy/dist/pypy/annotation/bookkeeper.py (original)
+++ pypy/dist/pypy/annotation/bookkeeper.py Sun Oct 2 18:52:51 2005
@@ -14,7 +14,7 @@
from pypy.interpreter.argument import Arguments, ArgErr
from pypy.rpython.rarithmetic import r_uint
from pypy.rpython.objectmodel import r_dict
-from pypy.tool.unionfind import UnionFind
+from pypy.tool.algo.unionfind import UnionFind
from pypy.rpython import lltype
from pypy.rpython.memory import lladdress
Modified: pypy/dist/pypy/tool/algo/sparsemat.py
==============================================================================
--- pypy/dist/pypy/tool/math/sparsemat.py (original)
+++ pypy/dist/pypy/tool/algo/sparsemat.py Sun Oct 2 18:52:51 2005
@@ -72,24 +72,3 @@
total -= a * solution[j]
solution[i] = total / line[i]
return solution
-
-
-def test_sparsemat1():
- import py
- M = SparseMatrix(4)
- M[0,0] = M[1,1] = M[2,2] = M[3,3] = 1
- M[0,1] = -1.0
- M[1,2] = M[1,3] = -0.5
- M[2,1] = -1.0
- res = M.solve([4, 5, 4, 1])
- assert res == [19, 15, 19, 1]
-
-def test_sparsemat2():
- import py
- M = SparseMatrix(4)
- M[0,0] = M[1,1] = M[2,2] = M[3,3] = 1
- M[0,1] = -1.0
- M[1,2] = M[1,3] = -0.5
- M[2,1] = M[2,3] = -0.5
- res = M.solve([6, 3, 6, 0])
- assert res == [14, 8, 10, 0]
Modified: pypy/dist/pypy/tool/algo/test/test_graphlib.py
==============================================================================
--- pypy/dist/pypy/tool/math/test/test_graphlib.py (original)
+++ pypy/dist/pypy/tool/algo/test/test_graphlib.py Sun Oct 2 18:52:51 2005
@@ -1,7 +1,5 @@
import autopath
-from pypy.tool.math.graphlib import *
-
-# XXX transform.py is difficult to test directly
+from pypy.tool.algo.graphlib import *
edges = {
'A': [Edge('A','B'), Edge('A','C')],
Added: pypy/dist/pypy/tool/algo/test/test_sparsemat.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/tool/algo/test/test_sparsemat.py Sun Oct 2 18:52:51 2005
@@ -0,0 +1,23 @@
+import autopath
+from pypy.tool.algo.sparsemat import *
+
+
+def test_sparsemat1():
+ import py
+ M = SparseMatrix(4)
+ M[0,0] = M[1,1] = M[2,2] = M[3,3] = 1
+ M[0,1] = -1.0
+ M[1,2] = M[1,3] = -0.5
+ M[2,1] = -1.0
+ res = M.solve([4, 5, 4, 1])
+ assert res == [19, 15, 19, 1]
+
+def test_sparsemat2():
+ import py
+ M = SparseMatrix(4)
+ M[0,0] = M[1,1] = M[2,2] = M[3,3] = 1
+ M[0,1] = -1.0
+ M[1,2] = M[1,3] = -0.5
+ M[2,1] = M[2,3] = -0.5
+ res = M.solve([6, 3, 6, 0])
+ assert res == [14, 8, 10, 0]
Modified: pypy/dist/pypy/translator/backendopt/inline.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/inline.py (original)
+++ pypy/dist/pypy/translator/backendopt/inline.py Sun Oct 2 18:52:51 2005
@@ -8,7 +8,7 @@
from pypy.annotation import model as annmodel
from pypy.rpython.lltype import Bool, typeOf
from pypy.rpython import rmodel
-from pypy.translator.backendopt import sparsemat
+from pypy.tool.algo import sparsemat
from pypy.translator.backendopt.support import log
BASE_INLINE_THRESHOLD = 32.4 # just enough to inline add__Int_Int()
Modified: pypy/dist/pypy/translator/backendopt/malloc.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/malloc.py (original)
+++ pypy/dist/pypy/translator/backendopt/malloc.py Sun Oct 2 18:52:51 2005
@@ -1,6 +1,6 @@
from pypy.objspace.flow.model import Variable, Constant, Block, Link
from pypy.objspace.flow.model import SpaceOperation, traverse, checkgraph
-from pypy.tool.unionfind import UnionFind
+from pypy.tool.algo.unionfind import UnionFind
from pypy.rpython import lltype
from pypy.translator.simplify import remove_identical_vars
from pypy.translator.backendopt.support import log
Modified: pypy/dist/pypy/translator/backendopt/ssa.py
==============================================================================
--- pypy/dist/pypy/translator/backendopt/ssa.py (original)
+++ pypy/dist/pypy/translator/backendopt/ssa.py Sun Oct 2 18:52:51 2005
@@ -1,5 +1,5 @@
from pypy.objspace.flow.model import Variable, mkentrymap, flatten, Block
-from pypy.tool.unionfind import UnionFind
+from pypy.tool.algo.unionfind import UnionFind
class DataFlowFamilyBuilder:
"""Follow the flow of the data in the graph. Builds a UnionFind grouping
More information about the Pypy-commit
mailing list