Index
__all__ = ('Chispa', 'Color', 'ColumnsNotEqualError', 'DataFramesNotEqualError', 'DefaultFormats', 'Format', 'FormattingConfig', 'SchemasNotEqualError', 'Style', 'assert_approx_column_equality', 'assert_approx_df_equality', 'assert_basic_rows_equality', 'assert_column_equality', 'assert_df_equality')
module-attribute
¶
Chispa
¶
Source code in chispa/__init__.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
formats = FormattingConfig()
instance-attribute
¶
__init__(formats=None)
¶
Source code in chispa/__init__.py
25 26 27 28 29 30 31 | |
assert_df_equality(df1, df2, ignore_nullable=False, transforms=None, allow_nan_equality=False, ignore_column_order=False, ignore_row_order=False, underline_cells=False, ignore_metadata=False, ignore_columns=None)
¶
Source code in chispa/__init__.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
Color
¶
Bases: str, Enum
Enum for terminal colors. Each color is represented by its corresponding ANSI escape code.
Source code in chispa/formatting/formats.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
BLACK = '\x1b[30m'
class-attribute
instance-attribute
¶
BLUE = '\x1b[34m'
class-attribute
instance-attribute
¶
CYAN = '\x1b[36m'
class-attribute
instance-attribute
¶
DARK_GRAY = '\x1b[90m'
class-attribute
instance-attribute
¶
GREEN = '\x1b[32m'
class-attribute
instance-attribute
¶
LIGHT_BLUE = '\x1b[94m'
class-attribute
instance-attribute
¶
LIGHT_CYAN = '\x1b[96m'
class-attribute
instance-attribute
¶
LIGHT_GRAY = '\x1b[37m'
class-attribute
instance-attribute
¶
LIGHT_GREEN = '\x1b[92m'
class-attribute
instance-attribute
¶
LIGHT_PURPLE = '\x1b[95m'
class-attribute
instance-attribute
¶
LIGHT_RED = '\x1b[91m'
class-attribute
instance-attribute
¶
LIGHT_YELLOW = '\x1b[93m'
class-attribute
instance-attribute
¶
PURPLE = '\x1b[35m'
class-attribute
instance-attribute
¶
RED = '\x1b[31m'
class-attribute
instance-attribute
¶
WHITE = '\x1b[97m'
class-attribute
instance-attribute
¶
YELLOW = '\x1b[33m'
class-attribute
instance-attribute
¶
ColumnsNotEqualError
¶
Bases: Exception
The columns are not equal
Source code in chispa/column_comparer.py
9 10 11 12 | |
DataFramesNotEqualError
¶
Bases: Exception
The DataFrames are not equal
Source code in chispa/dataframe_comparer.py
54 55 56 57 | |
DefaultFormats
dataclass
¶
This class is now deprecated and should be removed in a future release.
Source code in chispa/default_formats.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |
matched_cells = field(default_factory=lambda: ['blue'])
class-attribute
instance-attribute
¶
matched_rows = field(default_factory=lambda: ['blue'])
class-attribute
instance-attribute
¶
mismatched_cells = field(default_factory=lambda: ['red', 'underline'])
class-attribute
instance-attribute
¶
mismatched_rows = field(default_factory=lambda: ['red'])
class-attribute
instance-attribute
¶
__init__(mismatched_rows=lambda: ['red'](), matched_rows=lambda: ['blue'](), mismatched_cells=lambda: ['red', 'underline'](), matched_cells=lambda: ['blue']())
¶
__post_init__()
¶
Source code in chispa/default_formats.py
18 19 20 21 | |
Format
dataclass
¶
Data class to represent text formatting with color and style.
Attributes:
| Name | Type | Description |
|---|---|---|
color |
Color | None
|
The color for the text. |
style |
list[Style] | None
|
A list of styles for the text. |
Source code in chispa/formatting/formats.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
color = None
class-attribute
instance-attribute
¶
style = None
class-attribute
instance-attribute
¶
__init__(color=None, style=None)
¶
from_dict(format_dict)
classmethod
¶
Create a Format instance from a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format_dict
|
dict
|
A dictionary with keys 'color' and/or 'style'. |
required |
Source code in chispa/formatting/formats.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
from_list(values)
classmethod
¶
Create a Format instance from a list of strings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
list[str]
|
A list of strings representing colors and styles. |
required |
Source code in chispa/formatting/formats.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
FormattingConfig
¶
Class to manage and parse formatting configurations.
Source code in chispa/formatting/formatting_config.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
VALID_KEYS = {'color', 'style'}
class-attribute
instance-attribute
¶
matched_cells = self._parse_format(matched_cells)
instance-attribute
¶
matched_rows = self._parse_format(matched_rows)
instance-attribute
¶
mismatched_cells = self._parse_format(mismatched_cells)
instance-attribute
¶
mismatched_rows = self._parse_format(mismatched_rows)
instance-attribute
¶
__init__(mismatched_rows=Format(Color.RED), matched_rows=Format(Color.BLUE), mismatched_cells=Format(Color.RED, [Style.UNDERLINE]), matched_cells=Format(Color.BLUE))
¶
Initializes the FormattingConfig with given or default formatting.
Each of the arguments can be provided as a Format object or a dictionary with the following keys:
- 'color': A string representing a color name, which should be one of the valid colors:
['black', 'red', 'green', 'yellow', 'blue', 'purple', 'cyan', 'light_gray',
'dark_gray', 'light_red', 'light_green', 'light_yellow', 'light_blue',
'light_purple', 'light_cyan', 'white'].
- 'style': A string or list of strings representing styles, which should be one of the valid styles:
['bold', 'underline', 'blink', 'invert', 'hide'].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mismatched_rows
|
Format | dict
|
Format or dictionary for mismatched rows. |
Format(RED)
|
matched_rows
|
Format | dict
|
Format or dictionary for matched rows. |
Format(BLUE)
|
mismatched_cells
|
Format | dict
|
Format or dictionary for mismatched cells. |
Format(RED, [UNDERLINE])
|
matched_cells
|
Format | dict
|
Format or dictionary for matched cells. |
Format(BLUE)
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the dictionary contains invalid keys or values. |
Source code in chispa/formatting/formatting_config.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
SchemasNotEqualError
¶
Bases: Exception
The schemas are not equal
Source code in chispa/schema_comparer.py
14 15 16 17 | |
Style
¶
Bases: str, Enum
Enum for text styles. Each style is represented by its corresponding ANSI escape code.
Source code in chispa/formatting/formats.py
33 34 35 36 37 38 39 40 41 42 43 | |
assert_approx_column_equality(df, col_name1, col_name2, precision)
¶
Source code in chispa/column_comparer.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
assert_approx_df_equality(df1, df2, precision, ignore_nullable=False, transforms=None, allow_nan_equality=False, ignore_column_order=False, ignore_row_order=False, ignore_columns=None, formats=None)
¶
Source code in chispa/dataframe_comparer.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
assert_basic_rows_equality(rows1, rows2, underline_cells=False, formats=None)
¶
Source code in chispa/rows_comparer.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
assert_column_equality(df, col_name1, col_name2)
¶
Source code in chispa/column_comparer.py
15 16 17 18 19 20 21 22 23 24 25 26 27 | |
assert_df_equality(df1, df2, ignore_nullable=False, transforms=None, allow_nan_equality=False, ignore_column_order=False, ignore_row_order=False, underline_cells=False, ignore_metadata=False, ignore_columns=None, formats=None)
¶
Source code in chispa/dataframe_comparer.py
60 61 62 63 64 65 66 67 68 69 70 71 72 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 99 100 101 102 103 104 105 106 107 | |