Utility routines (sisl.utils)

Several utility functions are used throughout sisl.

Range routines

array_arange(start[, end, n, dtype]) Creates a single array from a sequence of numpy.arange
strmap(func, s[, start, end, sep]) Parse a string as though it was a slice and map all entries using func.
strseq(cast, s[, start, end]) Accept a string and return the casted tuples of content based on ranges.
lstranges(lst[, cast, end]) Convert a strmap list into expanded ranges
erange(start, step[, end]) Returns the range with both ends includede
list2str(lst) Convert a list of elements into a string of ranges
fileindex(f[, cast]) Parses a filename string into the filename and the indices.

Miscellaneous routines

str_spec(name) Split into a tuple of name and specifier, delimited by {...}.
direction(d) Return the index coordinate index corresponding to the Cartesian coordinate system.
angle(s[, rad, in_rad]) Convert the input string to an angle, either radians or degrees.
iter_shape(shape) Generator for iterating a shape by returning consecutive slices
math_eval(expr) Evaluate a mathematical expression using a safe evaluation method
add_action(namespace, action, args, kwargs) Add an action to the list of actions to be runned
angle(s[, rad, in_rad]) Convert the input string to an angle, either radians or degrees.
argv_negative_fix(argv) Fixes argv list by adding a space for input that may be float’s
array_arange(start[, end, n, dtype]) Creates a single array from a sequence of numpy.arange
collect_action(func) Decorator for collecting actions until the namespace attrbitute _actions_run is True.
collect_arguments(argv[, input, ...]) Function for returning the actual arguments depending on the input options.
collect_input(argv) Function for returning the input file
default_ArgumentParser(*A_args, **A_kwargs) Decorator for routines which takes a parser as argument and ensures that it is _not_ None.
default_namespace(**kwargs) Ensure the namespace can be used to collect and run the actions
direction(d) Return the index coordinate index corresponding to the Cartesian coordinate system.
erange(start, step[, end]) Returns the range with both ends includede
fileindex(f[, cast]) Parses a filename string into the filename and the indices.
iter_shape(shape) Generator for iterating a shape by returning consecutive slices
list2str(lst) Convert a list of elements into a string of ranges
lstranges(lst[, cast, end]) Convert a strmap list into expanded ranges
math_eval(expr) Evaluate a mathematical expression using a safe evaluation method
merge_instances(*args, **kwargs) Merges an arbitrary number of instances together.
run_actions(func) Decorator for running collected actions.
run_collect_action(func) Decorator for collecting actions and running.
str_spec(name) Split into a tuple of name and specifier, delimited by {...}.
strmap(func, s[, start, end, sep]) Parse a string as though it was a slice and map all entries using func.
strseq(cast, s[, start, end]) Accept a string and return the casted tuples of content based on ranges.