| Home | Trees | Indices | Help |
|
|---|
|
|
General utility functions and classes.
$Id: utils.py 8026 2008-02-19 14:30:05Z ceball $
Version: $Revision: 8026 $
|
|||
|
Struct A simple structure class, taking keyword args and assigning them to attributes. |
|||
|
Singleton The singleton pattern. |
|||
|
ExtraPickler Provides a simple means to include arbitrary attributes from modules when pickling. |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Returns a list of the indices needed to address or loop over all the elements of a 1D or 2D matrix with the given shape. E.g.: flat_indices((3,)) == [0,1,2] |
Flattens a list. Written by Bearophile as published on the www.python.org newsgroups. Pulled into Topographica 3/5/2005. |
Evaluates the given string in __main__, and converts it to a float. The string can contain any expression that will evaluate to a number. The expression can use any variables or functions that are defined in the main namespace. See string.atof() for more details about the conversion from the evaluated string into a float. |
A range function that accepts float increments. Otherwise, works just as the inbuilt range() function. If inclusive is False, as in the default, the range is exclusive (not including the end value), as in the inbuilt range(). If inclusive is true, the range may include the end value. 'All theoretic restrictions apply, but in practice this is more useful than in theory.' From: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66472 |
Return the inverse of dictionary dict_. (I.e. return a dictionary with keys that are the values of dict_, and values that are the corresponding keys from dict_.) The values of dict_ must be unique. |
Returns the class name of x as a string with the leading package information removed. E.g. if x is of type "<class 'topo.base.sheet.Sheet'>", returns "Sheet" |
Profile the given command (supplied as a string), printing statistics about the top n functions when ordered according to sorting. sorting defaults to ordering by cumulative time and then internal time; see http://docs.python.org/lib/profile-stats.html for other sorting options. By default, the complete paths of files are not shown. If there are multiple files with the same name, you might wish to set strip_dirs=False to make it easier to follow the output. Examples:
profile('execfile("examples/hierarchical.ty")')
profile('topo.sim.run(10)')
profile('execfile("examples/lissom_oo_or.ty");topo.sim.run(20000)')
./topographica examples/hierarchical.ty -c "from topo.misc.utils import profile; profile('topo.sim.run(10)')" |
Select randomly from the given sequence. The weights, if given, should be a sequence the same length as seq, as would be passed to weighted_sample_idx(). |
Return an integer generated by sampling the discrete distribution represented by the sequence of weights. The integer will be in the range [0,len(weights)). The weights need not sum to unity, but can contain any non-negative values (e.g., [1 1 1 100] is a valid set of weights). To use weights from a 2D numpy array w, specify w.ravel() (not the w.flat iterator). |
Return the centroid of a weighted set of points as an array. The pts argument should be an array of points, one per row, and weights should be a vector of weights. |
Split x into its sign and absolute value. Returns a tuple (sign(x),abs(x)). Note: sign(0) = 1, unlike numpy.sign. |
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0beta1 on Thu Feb 21 15:25:02 2008 | http://epydoc.sourceforge.net |