From 55ee082a0286c4480c0b653ec398513ecd3e0ed3 Mon Sep 17 00:00:00 2001 From: Jerry Wu Date: Tue, 16 Apr 2024 21:47:00 +0800 Subject: [PATCH 1/7] Update _body.py comment out the unused variables --- great_tables/_body.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/great_tables/_body.py b/great_tables/_body.py index 0e6d158be..2df676db8 100644 --- a/great_tables/_body.py +++ b/great_tables/_body.py @@ -10,10 +10,10 @@ def body_reassemble(body: Body, row_groups: RowGroups, stub_df: Stub, boxhead: Boxhead) -> Body: - cols = [col_info.var for col_info in boxhead] + #cols = [col_info.var for col_info in boxhead] - start_final = get_row_reorder_df(row_groups, stub_df) - rows = [final for _, final in start_final] + #start_final = get_row_reorder_df(row_groups, stub_df) + #rows = [final for _, final in start_final] # TODO: once body is just a DataFrame, we can call reorder directly on it # return body.__class__(reorder(body.body, rows, cols)) From 88be7c5c8d2e9b021c03743dffe11478802e5052 Mon Sep 17 00:00:00 2001 From: Jerry Wu Date: Tue, 16 Apr 2024 21:47:49 +0800 Subject: [PATCH 2/7] Update _boxhead.py delete the unused variable --- great_tables/_boxhead.py | 1 - 1 file changed, 1 deletion(-) diff --git a/great_tables/_boxhead.py b/great_tables/_boxhead.py index f1963b7ed..41ea5f634 100644 --- a/great_tables/_boxhead.py +++ b/great_tables/_boxhead.py @@ -90,7 +90,6 @@ def cols_label(self: GTSelf, **kwargs: Any) -> GTSelf: return self mod_columns = list(kwargs.keys()) - new_labels = list(kwargs.values()) # Get the full list of column names for the data column_names = self._boxhead._get_columns() From ceeecddc1d41b6f1dd5fcf5648b89c59de7fe567 Mon Sep 17 00:00:00 2001 From: Jerry Wu Date: Tue, 16 Apr 2024 21:48:39 +0800 Subject: [PATCH 3/7] Update _databackend.py simplify the Boolean comparison --- great_tables/_databackend.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/great_tables/_databackend.py b/great_tables/_databackend.py index 9b7a14ab2..e61f317f8 100644 --- a/great_tables/_databackend.py +++ b/great_tables/_databackend.py @@ -31,7 +31,6 @@ def __subclasshook__(cls, subclass): continue else: parent_candidate = _load_class(mod_name, cls_name) - if issubclass(subclass, parent_candidate): - return True + return issubclass(subclass, parent_candidate) return NotImplemented From 488cbd4de7179b97b091df612f42d2600bd8a208 Mon Sep 17 00:00:00 2001 From: Jerry Wu Date: Tue, 16 Apr 2024 21:50:23 +0800 Subject: [PATCH 4/7] Update _utils.py * Using `if` sounds more pythonic from my perspective. * `return` is redundant here. --- great_tables/_utils.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/great_tables/_utils.py b/great_tables/_utils.py index d7ccbb0fc..c98d999df 100644 --- a/great_tables/_utils.py +++ b/great_tables/_utils.py @@ -64,7 +64,7 @@ def _assert_str_list(x: Any) -> None: def _assert_str_in_set(x: str, set: List[str]): - while x not in set: + if x not in set: raise AssertionError(f"The string `{x}` is not part of the defined `set`.") @@ -72,8 +72,6 @@ def _assert_list_is_subset(x: List[Any], set_list: List[Any]) -> None: if not set(x).issubset(set(set_list)): raise AssertionError("The columns provided are not present in the table.") - return - def _str_scalar_to_list(x: str): _assert_str_scalar(x) From cdaa6700761b8040c90ce619e9d573a905e03256 Mon Sep 17 00:00:00 2001 From: Jerry Wu Date: Tue, 16 Apr 2024 21:56:06 +0800 Subject: [PATCH 5/7] Update _body.py fix black --- great_tables/_body.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/great_tables/_body.py b/great_tables/_body.py index 2df676db8..df7819674 100644 --- a/great_tables/_body.py +++ b/great_tables/_body.py @@ -10,10 +10,10 @@ def body_reassemble(body: Body, row_groups: RowGroups, stub_df: Stub, boxhead: Boxhead) -> Body: - #cols = [col_info.var for col_info in boxhead] + # cols = [col_info.var for col_info in boxhead] - #start_final = get_row_reorder_df(row_groups, stub_df) - #rows = [final for _, final in start_final] + # start_final = get_row_reorder_df(row_groups, stub_df) + # rows = [final for _, final in start_final] # TODO: once body is just a DataFrame, we can call reorder directly on it # return body.__class__(reorder(body.body, rows, cols)) From a0fd0efeed08541761bce72aec6862f061d83f86 Mon Sep 17 00:00:00 2001 From: Jerry Wu Date: Tue, 16 Apr 2024 22:25:53 +0800 Subject: [PATCH 6/7] Update _databackend.py I'll revert this commit because the logic is different from the original code. --- great_tables/_databackend.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/great_tables/_databackend.py b/great_tables/_databackend.py index e61f317f8..9b7a14ab2 100644 --- a/great_tables/_databackend.py +++ b/great_tables/_databackend.py @@ -31,6 +31,7 @@ def __subclasshook__(cls, subclass): continue else: parent_candidate = _load_class(mod_name, cls_name) - return issubclass(subclass, parent_candidate) + if issubclass(subclass, parent_candidate): + return True return NotImplemented From a7267818598ad17e523c18b33382c2c02ba6de34 Mon Sep 17 00:00:00 2001 From: Michael Chow Date: Tue, 16 Apr 2024 14:21:36 -0400 Subject: [PATCH 7/7] docs: leave note on body reordering --- great_tables/_body.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/great_tables/_body.py b/great_tables/_body.py index df7819674..594d1e369 100644 --- a/great_tables/_body.py +++ b/great_tables/_body.py @@ -10,11 +10,6 @@ def body_reassemble(body: Body, row_groups: RowGroups, stub_df: Stub, boxhead: Boxhead) -> Body: - # cols = [col_info.var for col_info in boxhead] - - # start_final = get_row_reorder_df(row_groups, stub_df) - # rows = [final for _, final in start_final] - - # TODO: once body is just a DataFrame, we can call reorder directly on it - # return body.__class__(reorder(body.body, rows, cols)) + # Note that this used to order the body based on groupings, but now that occurs in the + # renderer itself. return body.__class__(copy_data(body.body))