summarize_ndarray

summarize_ndarray#

penzai.treescope.ndarray_summarization.summarize_ndarray(array: np.ndarray | jax.Array, include_shape_and_dtype: bool = True) str[source]#

Summarizes an NDArray as a string.

The summaries generated by this function have one of the forms:

  • floatX(shape) mean ±std [min, max] zero:? nonzero:? nan:? inf:? -inf:?

  • intX(shape) [min, max] zero:? nonzero:?

  • bool(shape) true:? false:?

  • other_dtype(shape)

where ? represents the number of elements that have that property, and any property with no elements is omitted. When the array is empty, mean, std, min, and max are also omitted. When there are infinite elements, the mean and std are taken only over the finite ones, and nan is ignored for min/max.

Parameters:
  • array – An array to summarize.

  • include_shape_and_dtype – Whether to include the shape and dtype in the summary. If False, just summarizes the values.

Returns:

A summary of the array.