watex.utils.funcutils.shrunkformat#

watex.utils.funcutils.shrunkformat(text, chunksize=7, insert_at=None, sep=None)[source]#

format class and add ellipsis when classes are greater than maxview

Parameters
  • text – str - a text to shrunk and format. Can also be an iterable object.

  • chunksize – int, the size limit to keep in the formatage text. default is 7.

  • insert_at – str, the place to insert the ellipsis. If None, shrunk the text and put the ellipsis, between the text beginning and the text endpoint. Can be beginning, or end.

  • sep – str if the text is delimited by a kind of character, the sep parameters could be usefull so it would become a starting point for word counting. default is None which means word is counting from the space.

Example

>>> import numpy as np
>>> from watex.utils.funcutils import shrunkformat
>>> text=" I'm a long text and I will be shrunked and replaced by ellipsis."
>>> shrunkformat (text)
... 'Im a long ... and replaced by ellipsis.'
>>> shrunkformat (text, insert_at ='end')
...'Im a long ... '
>>> arr = np.arange(30)
>>> shrunkformat (arr, chunksize=10 )
... '0 1 2 3 4  ...  25 26 27 28 29'
>>> shrunkformat (arr, insert_at ='begin')
... ' ...  26 27 28 29'