signature_string_parts

odl.util.utility.signature_string_parts(posargs, optargs, mod='!r')[source]

Return stringified arguments as tuples.

Parameters
posargssequence

Positional argument values, always included in the returned string tuple.

optargssequence of 3-tuples

Optional arguments with names and defaults, given in the form:

[(name1, value1, default1), (name2, value2, default2), ...]

Only those parameters that are different from the given default are included as name=value keyword pairs.

Note: The comparison is done by using if value == default:, which is not valid for, e.g., NumPy arrays.

modstring or callable or sequence, optional

Format modifier(s) for the argument strings. In its most general form, mod is a sequence of 2 sequences pos_mod, opt_mod with len(pos_mod) == len(posargs) and len(opt_mod) == len(optargs). Each entry m in those sequences can be a string, resulting in the following stringification of arg:

arg_fmt = {{{}}}.format(m)
arg_str = arg_fmt.format(arg)

For a callable to_str, the stringification is simply arg_str = to_str(arg).

The entries pos_mod, opt_mod of mod can also be strings or callables instead of sequences, in which case the modifier applies to all corresponding arguments.

Finally, if mod is a string or callable, it is applied to all arguments.

The default behavior is to apply the “{!r}” (repr) conversion. For floating point scalars, the number of digits printed is determined by the precision value in NumPy’s printing options, which can be temporarily modified with npy_printoptions.

Returns
pos_stringstuple of str

The stringified positional arguments.

opt_stringstuple of str

The stringified optional arguments, not including the ones equal to their respective defaults.