plasmapy.utils.code_repr.call_string(f: Callable, args: Optional[Any] = None, kwargs: Optional[Dict[str, Any]] = None, max_items: numbers.Integral = 12)str

Approximate a call of a function or class with positional and keyword arguments.

  • f (callable) – A function, class, or other callable object.

  • args (tuple, list, or any object; optional) – A tuple or list containing positional arguments, or any other object if there is only one positional argument.

  • kwargs (dict, optional) – A dict containing keyword arguments.

  • max_items (int, optional) – The maximum number of items to include in a ndarray or Quantity; additional items will be truncated with an ellipsis. Defaults to 12.


Approximation to a call of f with args as positional arguments and kwargs as keyword arguments.

Return type



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 for astropy.units and np for numpy.


>>> call_string(int, 3.14159)
>>> call_string(int, args=(9.2,), kwargs={'base': 2})
'int(9.2, base=2)'