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

nngt.lib.InvalidArgument Error raised when an argument is invalid.
nngt.lib.delta_distrib([graph, elist, num, ...]) Delta distribution for edge attributes.
nngt.lib.find_idx_nearest(array, values) Find the indices of the nearest elements of values in a sorted array.
nngt.lib.gaussian_distrib(graph[, elist, ...]) Gaussian distribution for edge attributes.
nngt.lib.lin_correlated_distrib(graph[, ...])
nngt.lib.log_correlated_distrib(graph[, ...])
nngt.lib.lognormal_distrib(graph[, elist, ...])
nngt.lib.nonstring_container(obj) Returns true for any iterable which is not a string or byte sequence.
nngt.lib.not_implemented(*args, **kwargs)
nngt.lib.seed([seed]) Seed the random generator used by NNGT (i.e.
nngt.lib.uniform_distrib(graph[, elist, ...]) Uniform distribution for edge attributes.
nngt.lib.valid_gen_arguments(func)

Details

Various tools for random number generation, array searching and type testing.

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 (@todo)
  • 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 and values 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=1.0, std=0.2, **kwargs)[source]

Gaussian distribution for edge attributes.

Parameters:
  • graph (Graph or subclass) – Graph for which an edge attribute will be generated.
  • elist (@todo)
  • 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.
exception nngt.lib.InvalidArgument[source]

Error raised when an argument is invalid.

nngt.lib.lin_correlated_distrib(graph, elist=None, correl_attribute='betweenness', noise_scale=None, lower=0.0, upper=2.0, **kwargs)[source]
nngt.lib.log_correlated_distrib(graph, elist=None, correl_attribute='betweenness', noise_scale=None, lower=0.0, upper=2.0, **kwargs)[source]
nngt.lib.lognormal_distrib(graph, elist=None, num=None, position=1.0, scale=0.2, **kwargs)[source]
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=0.0, upper=1.5, **kwargs)[source]

Uniform distribution for edge attributes.

Parameters:
  • graph (Graph or subclass) – Graph for which an edge attribute will be generated.
  • elist (@todo)
  • 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.