|
25 | 25 | type_is_subclass_of_type_group, type_in_type_group, get_doc, |
26 | 26 | number_to_string, datetime_normalize, KEY_TO_VAL_STR, booleans, |
27 | 27 | np_ndarray, np_floating, get_numpy_ndarray_rows, RepeatedTimer, |
28 | | - TEXT_VIEW, TREE_VIEW, DELTA_VIEW, COLORED_VIEW, detailed__dict__, add_root_to_paths, |
| 28 | + TEXT_VIEW, TREE_VIEW, DELTA_VIEW, COLORED_VIEW, COLORED_COMPACT_VIEW, __dict__, add_root_to_paths, |
29 | 29 | np, get_truncate_datetime, dict_, CannotCompare, ENUM_INCLUDE_KEYS, |
30 | 30 | PydanticBaseModel, Opcode, SetOrdered, ipranges) |
31 | 31 | from deepdiff.serialization import SerializationMixin |
@@ -81,7 +81,7 @@ def _report_progress(_stats, progress_logger, duration): |
81 | 81 | PREVIOUS_DIFF_COUNT = 'PREVIOUS DIFF COUNT' |
82 | 82 | PREVIOUS_DISTANCE_CACHE_HIT_COUNT = 'PREVIOUS DISTANCE CACHE HIT COUNT' |
83 | 83 | CANT_FIND_NUMPY_MSG = 'Unable to import numpy. This must be a bug in DeepDiff since a numpy array is detected.' |
84 | | -INVALID_VIEW_MSG = 'The only valid values for the view parameter are text and tree. But {} was passed.' |
| 84 | +INVALID_VIEW_MSG = "view parameter must be one of 'text', 'tree', 'delta', 'colored' or 'colored_compact'. But {} was passed." |
85 | 85 | CUTOFF_RANGE_ERROR_MSG = 'cutoff_distance_for_pairs needs to be a positive float max 1.' |
86 | 86 | VERBOSE_LEVEL_RANGE_MSG = 'verbose_level should be 0, 1, or 2.' |
87 | 87 | PURGE_LEVEL_RANGE_MSG = 'cache_purge_level should be 0, 1, or 2.' |
@@ -366,7 +366,7 @@ def _group_by_sort_key(x): |
366 | 366 |
|
367 | 367 | self.tree.remove_empty_keys() |
368 | 368 | view_results = self._get_view_results(self.view) |
369 | | - if self.view == COLORED_VIEW: |
| 369 | + if self.view in {COLORED_VIEW, COLORED_COMPACT_VIEW}: |
370 | 370 | self._colored_view = view_results |
371 | 371 | else: |
372 | 372 | self.update(view_results) |
@@ -1764,7 +1764,9 @@ def _get_view_results(self, view): |
1764 | 1764 | elif view == DELTA_VIEW: |
1765 | 1765 | result = self._to_delta_dict(report_repetition_required=False) |
1766 | 1766 | elif view == COLORED_VIEW: |
1767 | | - result = ColoredView(self.t2, tree_results=self.tree, verbose_level=self.verbose_level) |
| 1767 | + result = ColoredView(self.t2, tree_results=result, verbose_level=self.verbose_level) |
| 1768 | + elif view == COLORED_COMPACT_VIEW: |
| 1769 | + result = ColoredView(self.t2, tree_results=result, verbose_level=self.verbose_level, compact=True) |
1768 | 1770 | else: |
1769 | 1771 | raise ValueError(INVALID_VIEW_MSG.format(view)) |
1770 | 1772 | return result |
@@ -1906,7 +1908,7 @@ def affected_root_keys(self): |
1906 | 1908 | return result |
1907 | 1909 |
|
1908 | 1910 | def __str__(self): |
1909 | | - if hasattr(self, '_colored_view') and self.view == COLORED_VIEW: |
| 1911 | + if hasattr(self, '_colored_view') and self.view in {COLORED_VIEW, COLORED_COMPACT_VIEW}: |
1910 | 1912 | return str(self._colored_view) |
1911 | 1913 | return super().__str__() |
1912 | 1914 |
|
|
0 commit comments