Is your feature request related to a problem?
I really like using icecream for debugging, but currently ic() only accepts positional arguments. It does not provide a way to pass additional keyword arguments that could be used by a custom argumentToString function.
Describe the solution you'd like
I'd like to be able to define a custom argumentToString for special types (e.g., numpy arrays) and pass options to it directly from the ic() call, such as:
@icecream.argumentToString.register(np.ndarray)
def _format_array(arr: np.ndarray, *, short_arrays: bool = True, **_kwargs) -> str:
if short_arrays:
return f"{arr.dtype}{arr.shape}(numpy)"
return repr(arr)
ic(arr) # I want short output here
ic(arr, short_arrays=False) # I want full output here
Describe alternatives you've considered
Currently, to switch between different formatting behaviors, I must reconfigure the output globally, which is less flexible:
ic.configureOutput(argToStringFunction=format_array)
ic(arr) # short output
ic.configureOutput(argToStringFunction=icecream.argumentToString)
ic(arr) # full output
Additional context
This feature would make icecream more flexible and ergonomic when working with complex data types and custom formatting needs.
Is your feature request related to a problem?
I really like using icecream for debugging, but currently
ic()only accepts positional arguments. It does not provide a way to pass additional keyword arguments that could be used by a customargumentToStringfunction.Describe the solution you'd like
I'd like to be able to define a custom
argumentToStringfor special types (e.g., numpy arrays) and pass options to it directly from theic()call, such as:Describe alternatives you've considered
Currently, to switch between different formatting behaviors, I must reconfigure the output globally, which is less flexible:
Additional context
This feature would make icecream more flexible and ergonomic when working with complex data types and custom formatting needs.