The utilities
module
A module which contains various utility methods for handling strings and floats.
- utilities.is_number(s)[source]
Test a string to see if it is a number.
- Parameters
s (string) – string which is being tested
- Returns
True
ifs
is a number, andFalse
otherwise- Return type
boolean
Note
This method allows “d” and “D” as an exponent (i.e. for Fortran style numbers).
- utilities.my_input()[source]
Select appropriate input function depending on whether python2 or python3 is being used.
- utilities.my_map(fct, lst)[source]
Systematically applies a function to a list of items. This deals with the python3 behaviour of map which returns a map object rather than a list.
- Parameters
fct (function) – the function to be applied to each element of a list
lst (list) – the list to which is applied the function
- utilities.sparse_print(filename, mat)[source]
Print a sparse matrix (for debug purposes only):
- Parameters
filename (string) – name of the file in which to print the matrix
mat (numpy array) – the matrix to be printed