-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 11fa23e
Showing
17 changed files
with
804 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
*.pyc | ||
|
||
.installed.cfg | ||
bin | ||
develop-eggs | ||
|
||
*.egg-info | ||
|
||
tmp | ||
build | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
syntax: glob | ||
|
||
.installed.cfg | ||
bin | ||
develop-eggs | ||
|
||
*.egg-info | ||
|
||
tmp | ||
build | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Development setup | ||
================= | ||
|
||
To create a buildout, | ||
|
||
$ python bootstrap.py | ||
$ bin/buildout | ||
|
||
Release HOWTO | ||
============= | ||
|
||
To make a release, | ||
|
||
1) Update release date/version in NEWS.txt and setup.py | ||
2) Run 'python setup.py sdist' | ||
3) Test the generated source distribution in dist/ | ||
4) Upload to PyPI: 'python setup.py sdist register upload' | ||
5) Increase version in setup.py (for next release) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
include README.rst | ||
include NEWS.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.. This is your project NEWS file which will contain the release notes. | ||
.. Example: http://www.python.org/download/releases/2.6/NEWS.txt | ||
.. The content of this file, along with README.rst, will appear in your | ||
.. project's PyPI page. | ||
|
||
News | ||
==== | ||
|
||
0.2a1 | ||
----- | ||
|
||
*Release date: UNRELEASED* | ||
|
||
* Example news entry for the in-development version | ||
|
||
|
||
0.1 | ||
--- | ||
|
||
*Release date: 15-Mar-2010* | ||
|
||
* Example news entry for a released version | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
This file requires editing | ||
========================== | ||
|
||
Note to the author: Please add something informative to this README *before* | ||
releasing your software, as `a little documentation goes a long way`_. Both | ||
README.rst (this file) and NEWS.txt (release notes) will be included in your | ||
package metadata which gets displayed in the PyPI page for your project. | ||
|
||
You can take a look at the README.txt of other projects, such as repoze.bfg | ||
(http://bfg.repoze.org/trac/browser/trunk/README.txt) for some ideas. | ||
|
||
.. _`a little documentation goes a long way`: http://www.martinaspeli.net/articles/a-little-documentation-goes-a-long-way | ||
|
||
Credits | ||
------- | ||
|
||
- `Distribute`_ | ||
- `Buildout`_ | ||
- `modern-package-template`_ | ||
|
||
.. _Buildout: http://www.buildout.org/ | ||
.. _Distribute: http://pypi.python.org/pypi/distribute | ||
.. _`modern-package-template`: http://pypi.python.org/pypi/modern-package-template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
############################################################################## | ||
# | ||
# Copyright (c) 2006 Zope Corporation and Contributors. | ||
# All Rights Reserved. | ||
# | ||
# This software is subject to the provisions of the Zope Public License, | ||
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. | ||
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED | ||
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS | ||
# FOR A PARTICULAR PURPOSE. | ||
# | ||
############################################################################## | ||
"""Bootstrap a buildout-based project | ||
Simply run this script in a directory containing a buildout.cfg. | ||
The script accepts buildout command-line options, so you can | ||
use the -c option to specify an alternate configuration file. | ||
$Id: bootstrap.py 102545 2009-08-06 14:49:47Z chrisw $ | ||
""" | ||
|
||
import os, shutil, sys, tempfile, urllib2 | ||
from optparse import OptionParser | ||
|
||
tmpeggs = tempfile.mkdtemp() | ||
|
||
is_jython = sys.platform.startswith('java') | ||
|
||
# parsing arguments | ||
parser = OptionParser() | ||
parser.add_option("-v", "--version", dest="version", | ||
help="use a specific zc.buildout version") | ||
parser.add_option("-d", "--distribute", | ||
action="store_true", dest="distribute", default=True, | ||
help="Use Disribute rather than Setuptools.") | ||
|
||
options, args = parser.parse_args() | ||
|
||
if options.version is not None: | ||
VERSION = '==%s' % options.version | ||
else: | ||
VERSION = '' | ||
|
||
USE_DISTRIBUTE = options.distribute | ||
args = args + ['bootstrap'] | ||
|
||
to_reload = False | ||
try: | ||
import pkg_resources | ||
if not hasattr(pkg_resources, '_distribute'): | ||
to_reload = True | ||
raise ImportError | ||
except ImportError: | ||
ez = {} | ||
if USE_DISTRIBUTE: | ||
exec urllib2.urlopen('http://python-distribute.org/distribute_setup.py' | ||
).read() in ez | ||
ez['use_setuptools'](to_dir=tmpeggs, download_delay=0, no_fake=True) | ||
else: | ||
exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py' | ||
).read() in ez | ||
ez['use_setuptools'](to_dir=tmpeggs, download_delay=0) | ||
|
||
if to_reload: | ||
reload(pkg_resources) | ||
else: | ||
import pkg_resources | ||
|
||
if sys.platform == 'win32': | ||
def quote(c): | ||
if ' ' in c: | ||
return '"%s"' % c # work around spawn lamosity on windows | ||
else: | ||
return c | ||
else: | ||
def quote (c): | ||
return c | ||
|
||
cmd = 'from setuptools.command.easy_install import main; main()' | ||
ws = pkg_resources.working_set | ||
|
||
if USE_DISTRIBUTE: | ||
requirement = 'distribute' | ||
else: | ||
requirement = 'setuptools' | ||
|
||
if is_jython: | ||
import subprocess | ||
|
||
assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd', | ||
quote(tmpeggs), 'zc.buildout' + VERSION], | ||
env=dict(os.environ, | ||
PYTHONPATH= | ||
ws.find(pkg_resources.Requirement.parse(requirement)).location | ||
), | ||
).wait() == 0 | ||
|
||
else: | ||
assert os.spawnle( | ||
os.P_WAIT, sys.executable, quote (sys.executable), | ||
'-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout' + VERSION, | ||
dict(os.environ, | ||
PYTHONPATH= | ||
ws.find(pkg_resources.Requirement.parse(requirement)).location | ||
), | ||
) == 0 | ||
|
||
ws.add_entry(tmpeggs) | ||
ws.require('zc.buildout' + VERSION) | ||
import zc.buildout.buildout | ||
zc.buildout.buildout.main(args) | ||
shutil.rmtree(tmpeggs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[buildout] | ||
parts = python scripts | ||
develop = . | ||
eggs = MapEquation | ||
|
||
[python] | ||
recipe = zc.recipe.egg | ||
interpreter = python | ||
eggs = ${buildout:eggs} | ||
|
||
[scripts] | ||
recipe = zc.recipe.egg:scripts | ||
eggs = ${buildout:eggs} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
numpy | ||
networkx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from setuptools import setup, find_packages | ||
import sys, os | ||
|
||
here = os.path.abspath(os.path.dirname(__file__)) | ||
README = open(os.path.join(here, 'README.rst')).read() | ||
NEWS = open(os.path.join(here, 'NEWS.txt')).read() | ||
|
||
|
||
version = '0.1' | ||
|
||
install_requires = [ | ||
numpy, | ||
networkx, | ||
# List your project dependencies here. | ||
# For more details, see: | ||
# http://packages.python.org/distribute/setuptools.html#declaring-dependencies | ||
] | ||
|
||
|
||
setup(name='MapEquation', | ||
version=version, | ||
description="Implementation of the MapEquation algorithm with networkx", | ||
long_description=README + '\n\n' + NEWS, | ||
classifiers=[ | ||
'Development Status :: 3 - Alpha', | ||
'Intended Audience :: Developers', | ||
'Intended Audience :: End Users/Desktop', | ||
'Intended Audience :: System Administrators', | ||
'Natural Language :: English', | ||
'Operating System :: POSIX', | ||
'Operating System :: Unix', | ||
'Operating System :: MacOS :: MacOS X', | ||
'Programming Language :: Python :: 2.6', | ||
'Programming Language :: Python :: 2.7', | ||
'Topic :: Graph', | ||
'License :: OSI Approved :: MIT License', | ||
'Environment :: Console', | ||
], | ||
keywords='graph, community detection', | ||
author='Vincent Gauthier', | ||
author_email='[email protected]', | ||
url='http://complex.luxbulb.org', | ||
license='MIT', | ||
packages=find_packages('src'), | ||
package_dir = {'': 'src'},include_package_data=True, | ||
zip_safe=True, | ||
install_requires=install_requires, | ||
test_suite='nose.collector', | ||
entry_points={ | ||
'console_scripts': | ||
['MapEquation=mapequation:main'] | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# ------------------------------------------------------------------------------- | ||
# Copyright (c) 2013 Vincent Gauthier Telecom SudParis. | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining | ||
# a copy of this software and associated documentation files (the | ||
# "Software"), to deal in the Software without restriction, including | ||
# without limitation the rights to use, copy, modify, merge, publish, | ||
# distribute, sublicense, and/or sell copies of the Software, and to | ||
# permit persons to whom the Software is furnished to do so, subject to | ||
# the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included | ||
# in all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
# ------------------------------------------------------------------------------- | ||
|
||
__author__ = """\n""".join(['Vincent Gauthier <[email protected]>']) | ||
|
||
import numpy as np | ||
|
||
class Bootstrap: | ||
def __init__(self, Graph, n=10, weight='weight'): | ||
self._Graph = Graph | ||
self._n = n | ||
self._weight_attribut = weight | ||
self._current = 0 | ||
# Test if each edge of the graph has an attribut 'weight' | ||
for u,v,edata in self._Graph.edges(data=True): | ||
if self._weight_attribut not in self._Graph[u][v]: | ||
raise AttributeError('The Graph has a missing weight attribut on his edges {} {}'.format(u,v)) | ||
|
||
def __iter__(self): | ||
return self | ||
|
||
def next(self): | ||
if self._current > self._n: | ||
raise StopIteration | ||
else: | ||
self._current += 1 | ||
return self.generate() | ||
|
||
def generate(self): | ||
''' | ||
Generate a random boostrap of the Graph (G) | ||
''' | ||
|
||
H = self._Graph.copy() | ||
for u,v,edata in H.edges(data=True): | ||
lam = int(edata[self._weight_attribut]) | ||
H[u][v]['weight'] = np.random.poisson(lam, 1).item(0 ) | ||
|
||
return H |
Oops, something went wrong.