~ubuntu-branches/ubuntu/trusty/python-networkx/trusty-proposed

« back to all changes in this revision

Viewing changes to networkx/utils.py

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2009-02-28 13:36:24 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090228133624-9l5rwi1ftlzc7b0l
* Upload to unstable now that lenny is released (yay).
* Fix FTBFS with python-support 0.90.3: no longer rely on its internal
  behaviour, and xnow set tests/test.py executable right after “setup.py
  install” (Closes: #517065).
* Drop executable bits from bz2 files.
* Update Vcs-* fields: move from DPMT's svn to collab-maint's git.
* Remote DPMT from Uploaders, following Piotr Ożarowski's request.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
"""
5
5
__author__ = """Aric Hagberg (hagberg@lanl.gov)\nDan Schult(dschult@colgate.edu)"""
6
 
__date__ = "$Date: 2005-06-15 08:30:40 -0600 (Wed, 15 Jun 2005) $"
7
 
__credits__ = """"""
8
 
__revision__ = "$Revision: 1029 $"
9
 
#    Copyright (C) 2004,2005 by 
 
6
#    Copyright (C) 2004-2008 by 
10
7
#    Aric Hagberg <hagberg@lanl.gov>
11
8
#    Dan Schult <dschult@colgate.edu>
12
9
#    Pieter Swart <swart@lanl.gov>
13
10
#    Distributed under the terms of the GNU Lesser General Public License
14
11
#    http://www.gnu.org/copyleft/lesser.html
15
12
import random
16
 
import networkx
17
13
 
18
14
### some cookbook stuff
19
15
 
335
331
    elif distribution is not None:
336
332
        cdf=cumulative_distribution(distribution)
337
333
    else:
338
 
        raise networkx.NetworkXError, \
 
334
        raise InputError, \
339
335
                  "discrete_sequence: distribution or cdistribution missing"
340
336
        
341
337
 
345
341
    # choose from CDF
346
342
    seq=[bisect.bisect_left(cdf,s)-1 for s in inputseq]
347
343
    return seq
348
 
 
349
 
def _test_suite():
350
 
    import doctest
351
 
    suite = doctest.DocFileSuite('tests/utils.txt',package='networkx')
352
 
    return suite
353
 
 
354
 
if __name__ == "__main__":
355
 
    import os
356
 
    import sys
357
 
    import unittest
358
 
    if sys.version_info[:2] < (2, 4):
359
 
        print "Python version 2.4 or later required for tests (%d.%d detected)." %  sys.version_info[:2]
360
 
        sys.exit(-1)
361
 
    # directory of networkx package (relative to this)
362
 
    nxbase=sys.path[0]+os.sep+os.pardir
363
 
    sys.path.insert(0,nxbase) # prepend to search path
364
 
    unittest.TextTestRunner().run(_test_suite())
365
 
    
366