utils#
 This module defines utility functions that are used across the package.
  clear_screen()  #
 Clears the terminal console.
Source code in picharsso/utils.py
 | 11 12 13 14 15 16 17 18 |  | 
  embolden(text)  #
 Modifies text to appear in a bold typeface, using ANSI escape codes.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| text | str | The subject text. | required | 
Returns:
| Type | Description | 
|---|---|
| str | The text in a bold typeface. | 
Source code in picharsso/utils.py
 | 21 22 23 24 25 26 27 28 29 30 31 |  | 
  ensure_rgb(image)  #
 Usually converts any Pillow image to its equivalent in the RGB mode.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| image | PIL.Image.Image | The subject image. | required | 
Returns:
| Type | Description | 
|---|---|
| PIL.Image.Image | The image in the  | 
Source code in picharsso/utils.py
 | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |  | 
  italicize(text)  #
 Modifies text to appear in italics, using ANSI escape codes.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| text | str | The subject text. | required | 
Returns:
| Type | Description | 
|---|---|
| str | The text in italics. | 
Source code in picharsso/utils.py
 | 60 61 62 63 64 65 66 67 68 69 70 |  | 
  submatrices(matrix, shape)  #
 Returns a rolling window view of a matrix, without overlapping, given the shape of the window.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| matrix | numpy.ndarray | The subject matrix. | required | 
| shape | Tuple[int, int] | The  | required | 
Returns:
| Type | Description | 
|---|---|
| numpy.ndarray | The rolling window view of the matrix. | 
Note
This operation doesn't account for the loss of border elements.
Source code in picharsso/utils.py
 | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |  | 
  terminal_size()  #
 Returns the size of the terminal window.
Returns:
| Type | Description | 
|---|---|
| (Tuple[int, int]) | The  | 
Note
When used while piping, this function usually returns the default terminal size, (24, 80).
Source code in picharsso/utils.py
 | 101 102 103 104 105 106 107 108 109 110 111 112 |  |