Helper module¶
These are helper functions to ease the definition of the high-level API of the PyNEST wrapper.
- class nest.lib.hl_api_helper.SuppressedDeprecationWarning(no_dep_funcs)¶
Bases:
object
Context manager turning off deprecation warnings for given methods.
Think thoroughly before use. This context should only be used as a way to make sure examples do not display deprecation warnings, that is, used in functions called from examples, and not as a way to make tedious deprecation warnings dissapear.
- nest.lib.hl_api_helper.broadcast(item, length, allowed_types, name='item')¶
Broadcast item to given length.
- nest.lib.hl_api_helper.deprecated(alt_func_name, text=None)¶
Decorator for deprecated functions.
Shows a warning and calls the original function.
- nest.lib.hl_api_helper.get_parameters(nc, param)¶
Get parameters from nodes.
Used by NodeCollections get() function.
- Parameters:
nc (NodeCollection) – nodes to get values from
param (string or list of strings) – string or list of string naming model properties.
- Returns:
int, list – param is a string so the value(s) is returned
dict – param is a list of string so a dictionary is returned
- nest.lib.hl_api_helper.get_parameters_hierarchical_addressing(nc, params)¶
Get parameters from nodes, hierarchical case.
Used by NodeCollections get() function.
- Parameters:
nc (NodeCollection) – nodes to get values from
params (tuple) – first value in the tuple should be a string, second can be a string or a list of string. The first value corresponds to the path into the hierarchical structure while the second value corresponds to the name(s) of the desired properties.
- Returns:
int, list – params[-1] is a string so the value(s) is returned
dict – params[-1] is a list of string so a dictionary is returned
- nest.lib.hl_api_helper.get_unistring_type()¶
Returns string type dependent on python version.
- Returns:
Depending on Python version
- Return type:
str or basestring
- nest.lib.hl_api_helper.get_wrapped_text(text, width=80)¶
Formats a given multiline string to wrap at a given width, while preserving newlines (and removing excessive whitespace).
- nest.lib.hl_api_helper.is_coercible_to_sli_array(seq)¶
Checks whether a given object is coercible to a SLI array
- nest.lib.hl_api_helper.is_iterable(seq)¶
Return True if the given object is an iterable, False otherwise.
- nest.lib.hl_api_helper.is_literal(obj)¶
Check whether obj is a “literal”: a unicode string or SLI literal
- nest.lib.hl_api_helper.is_sequence_of_connections(seq)¶
Checks whether low-level API accepts seq as a sequence of connections.
- nest.lib.hl_api_helper.is_sequence_of_node_ids(seq)¶
Checks whether the argument is a potentially valid sequence of node IDs (non-negative integers).
- nest.lib.hl_api_helper.is_string(obj)¶
Check whether obj is a unicode string
- nest.lib.hl_api_helper.load_help(obj)¶
Returns documentation of the given object in RST format
- Parameters:
obj (string) – Object to display help for
- Returns:
The documentation of the object or None if no help is available
- Return type:
string
- nest.lib.hl_api_helper.model_deprecation_warning(model)¶
Checks whether the model is to be removed in a future version of NEST. If so, a deprecation warning is issued.
- Parameters:
model (str) – Name of model
- nest.lib.hl_api_helper.restructure_data(result, keys)¶
Restructure list of status dictionaries or list of parameter values to dict with lists or single list or int.
- nest.lib.hl_api_helper.show_deprecation_warning(func_name, alt_func_name=None, text=None)¶
Shows a deprecation warning for a function.