Skip to content

Commit

Permalink
Merge pull request #13 from stephenhky/removefortran
Browse files Browse the repository at this point in the history
Remove Fortran components
  • Loading branch information
stephenhky authored Dec 31, 2021
2 parents 3c7d94b + c33bae6 commit b5bd8bf
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 107 deletions.
11 changes: 2 additions & 9 deletions graphflow/pagerank/GooglePageRank.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import numpy as np

from .f90pagerank import f90pagerank as fpr
from .cpagerank import pagerank_cython
from .. import L1norm, PageRankLanguage

Expand All @@ -15,12 +14,6 @@ def GoogleMatrix(digraph, beta):
return A, nodedict


def CalculatePageRankFromAdjacencyMatrix_Fortran(adjMatrix, nodes, eps=1e-4, maxstep=1000):
r = fpr.compute_pagerank(adjMatrix, eps, maxstep)
nodepr = {node: r[nodes[node]] for node in nodes}
return nodepr


def CalculatePageRankFromAdjacencyMatrix_Cython(adjMatrix, nodes, eps=1e-4, maxstep=1000):
return pagerank_cython(adjMatrix, nodes, eps, maxstep)

Expand All @@ -40,12 +33,12 @@ def CalculatePageRankFromAdjacencyMatrix_Python(adjMatrix, nodes, eps=1e-4, maxs


def CalculatePageRankFromAdjacencyMatrix(adjMatrix, nodes, eps=1e-4, maxstep=1000,
language=PageRankLanguage.FORTRAN,
language=PageRankLanguage.CYTHON,
fortran=True):
if not fortran:
warnings.warn('The boolean variable "fortran" is deprecated.')
if language == PageRankLanguage.FORTRAN:
return CalculatePageRankFromAdjacencyMatrix_Fortran(adjMatrix, nodes, eps=eps, maxstep=maxstep)
raise ValueError('Fortran is no longer supported.')
elif language == PageRankLanguage.CYTHON:
return CalculatePageRankFromAdjacencyMatrix_Cython(adjMatrix, nodes, eps=eps, maxstep=maxstep)
else:
Expand Down
57 changes: 0 additions & 57 deletions graphflow/pagerank/f90pagerank.f90

This file was deleted.

25 changes: 0 additions & 25 deletions graphflow/pagerank/f90pagerank.pyf

This file was deleted.

13 changes: 3 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# https://stackoverflow.com/questions/7932028/setup-py-for-packages-that-depend-on-both-cython-and-f2py

from setuptools import setup
import numpy as np

try:
from Cython.Build import cythonize
Expand All @@ -14,14 +15,6 @@
dynprog_ext_modules = [Extension('graphflow.pagerank.cpagerank',
sources=['graphflow/pagerank/cpagerank.c'])]

import numpy as np
from numpy.distutils.core import setup
from numpy.distutils.core import Extension as fortranExtension

fortran_ext_modules = [fortranExtension('graphflow.pagerank.f90pagerank',
sources=['graphflow/pagerank/f90pagerank.f90',
'graphflow/pagerank/f90pagerank.pyf'])]


def readme():
with open('README.md') as f:
Expand All @@ -33,7 +26,7 @@ def install_requirements():


setup(name='graphflow',
version="0.4.2",
version="0.4.3a1",
description="Algorithms for Graph Flow Analysis",
long_description="Numerical routines for analyzing data represented by graphs",
classifiers=[
Expand Down Expand Up @@ -67,7 +60,7 @@ def install_requirements():
'pandas',
],
include_dirs=[np.get_include()],
ext_modules=fortran_ext_modules+dynprog_ext_modules,
ext_modules=dynprog_ext_modules,
include_package_data=True,
test_suite="test",
zip_safe=False)
Expand Down
13 changes: 7 additions & 6 deletions test/test_pagerank.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,13 @@ def setUp(self):
self.googlematrix, self.nodedict = graphflow.pagerank.GooglePageRank.GoogleMatrix(graph, 0.15)

def testNetwork_fortran(self):
pagerank = graphflow.pagerank.GooglePageRank.CalculatePageRankFromAdjacencyMatrix(self.googlematrix, self.nodedict, language=PageRankLanguage.FORTRAN)

self.assertEqual(len(pagerank), len(pagerank_answer))
self.assertEqual(len(set(pagerank.keys()).intersection(set(pagerank_answer.keys()))), len(pagerank))
for name in pagerank:
self.assertAlmostEqual(pagerank[name], pagerank_answer[name], places=5)
self.assertRaises(
ValueError,
graphflow.pagerank.GooglePageRank.CalculatePageRankFromAdjacencyMatrix,
adjMatrix=self.googlematrix,
nodes=self.nodedict,
language=PageRankLanguage.FORTRAN
)

def testNetwork_python(self):
pagerank = graphflow.pagerank.GooglePageRank.CalculatePageRankFromAdjacencyMatrix(self.googlematrix, self.nodedict, language=PageRankLanguage.PYTHON)
Expand Down

0 comments on commit b5bd8bf

Please sign in to comment.