stouputils.print.debugging module#
- whatisit(*values: ~typing.Any, print_function: ~collections.abc.Callable[[...], None] = <function debug>, flush: bool = True, max_length: int = 250, color: str = '\x1b[96m', text: str = 'What is it?', **print_kwargs: ~typing.Any) None[source]#
Print the type of each value and the value itself, with its id and length/shape.
The output format is: “type, <id id_number>: (length/shape) value”
- Parameters:
values – Values to print
print_function – Function to use to print the values (default: debug())
max_length – Maximum length of the value string to print (default: 250)
color – Color of the message (default: CYAN)
text – Text in the message (replaces “DEBUG”)
print_kwargs – Keyword arguments to pass to the print function
- describe_value(
- value: Any,
- max_length: int = 250,
The line
whatisit()prints for one value:type, <id id_number>: (metadata) value.- Parameters:
max_length – Characters of the value’s string kept, the rest being replaced by
....
- value_metadata(value: Any) list[str][source]#
What a value exposes among dtype, size in bytes, device, shape or length, and its min and max, as
"name: value".A CPU device is left out, and min and max only appear when they differ.
>>> value_metadata([1, 5, 3]) ['length: 3', 'min: 1', 'max: 5'] >>> value_metadata("abc") ['length: 3']
- first_attribute_entry(
- value: Any,
- names: tuple[str, ...],
"name: value"for the first of these attributes the value holds, None when it holds none or its device is the CPU.
- breakpoint(*values: ~typing.Any, print_function: ~collections.abc.Callable[[...], None] = <function warning>, flush: bool = True, max_length: int = 1000, color: str = '\x1b[96m', text: str = 'BREAKPOINT (press Enter)', **print_kwargs: ~typing.Any) None[source]#
Breakpoint function, pause the program and print the values.
- Parameters:
values – Values to print
print_function – Function to use to print the values (default: warning())
max_length – Maximum length of the value string to print (default: 1000)
color – Color of the message (default: CYAN)
text – Text in the message (replaces “WARNING”)
print_kwargs – Keyword arguments to pass to the print function