Lib module#
Tools for the other modules.
Warning
These tools have been designed primarily for internal use throughout the
library and often work only in very specific situations (e.g.
find_idx_nearest()
works only on sorted arrays), so make
sure you read their doc carefully before using them.
Content#
Error raised when an argument is invalid. |
|
|
Delta distribution for edge attributes. |
|
Find the indices of the nearest elements of values in a sorted array. |
|
Gaussian distribution for edge attributes. |
|
Return whether the object is an integer |
|
Return whether the object is iterable |
|
|
|
|
|
Lognormal distribution for edge attributes. |
Returns true for any iterable which is not a string or byte sequence. |
|
|
Uniform distribution for edge attributes. |
Details#
- nngt.lib.delta_distrib(graph=None, elist=None, num=None, value=1.0, **kwargs)[source]#
Delta distribution for edge attributes.
- Parameters:
graph (
Graph
or subclass) – Graph for which an edge attribute will be generated.elist (list of edges, optional (default: all edges)) – Generate values for only a subset of edges.
value (float, optional (default: 1.)) – Value of the delta distribution.
Returns (
numpy.ndarray
) – Attribute value for each edge in graph.
- nngt.lib.find_idx_nearest(array, values)[source]#
Find the indices of the nearest elements of values in a sorted array.
Warning
Both
array
andvalues
should be numpy.array objects and array MUST be sorted in increasing order.- Parameters:
array (reference list or np.ndarray)
values (double, list or array of values to find in array)
- Returns:
idx (int or array representing the index of the closest value in array)
- nngt.lib.gaussian_distrib(graph, elist=None, num=None, avg=None, std=None, **kwargs)[source]#
Gaussian distribution for edge attributes.
- Parameters:
graph (
Graph
or subclass) – Graph for which an edge attribute will be generated.elist (list of edges, optional (default: all edges)) – Generate values for only a subset of edges.
avg (float, optional (default: 0.)) – Average of the Gaussian distribution.
std (float, optional (default: 1.5)) – Standard deviation of the Gaussian distribution.
Returns (
numpy.ndarray
) – Attribute value for each edge in graph.
- nngt.lib.lognormal_distrib(graph, elist=None, num=None, position=None, scale=None, **kwargs)[source]#
Lognormal distribution for edge attributes.
- Parameters:
graph (
Graph
or subclass) – Graph for which an edge attribute will be generated.elist (list of edges, optional (default: all edges)) – Generate values for only a subset of edges.
position (float, optional (default: 0.)) – Average of the normal distribution (i.e. log of the actual mean of the lognormal distribution).
scale (float, optional (default: 1.5)) – Standard deviation of the normal distribution.
Returns (
numpy.ndarray
) – Attribute value for each edge in graph.
- nngt.lib.nonstring_container(obj)[source]#
Returns true for any iterable which is not a string or byte sequence.
- nngt.lib.uniform_distrib(graph, elist=None, num=None, lower=None, upper=None, **kwargs)[source]#
Uniform distribution for edge attributes.
- Parameters:
graph (
Graph
or subclass) – Graph for which an edge attribute will be generated.elist (list of edges, optional (default: all edges)) – Generate values for only a subset of edges.
lower (float, optional (default: 0.)) – Min value of the uniform distribution.
upper (float, optional (default: 1.5)) – Max value of the uniform distribution.
Returns (
numpy.ndarray
) – Attribute value for each edge in graph.