call_string
- plasmapy.utils.code_repr.call_string( ) str [source]
Approximate a call of a function or class with positional and keyword arguments.
- Parameters:
f (callable) – A function, class, or other callable object.
args (
tuple
,list
, or anyobject
; optional) – Atuple
orlist
containing positional arguments, or any otherobject
if there is only one positional argument.kwargs (
dict
, optional) – Adict
containing keyword arguments.max_items (
int
, default: 12) – The maximum number of items to include in andarray
orQuantity
; additional items will be truncated with an ellipsis.
- Returns:
Approximation to a call of
f
withargs
as positional arguments andkwargs
as keyword arguments.- Return type:
See also
Notes
This function will generally provide an exact call string for most common types of simple positional and keyword arguments. When dealing with types that are not accounted for, this function will fall back on
repr
.This function assumes aliases of
u
forastropy.units
andnp
fornumpy
.Examples
>>> call_string(int, 3.14159) 'int(3.14159)' >>> call_string(int, args=(9.2,), kwargs={"base": 2}) 'int(9.2, base=2)'