Skip to content

Commit f2688b1

Browse files
authored
Rename get_sub_expressions to get_leaf_expressions (#265)
1 parent 365265e commit f2688b1

File tree

11 files changed

+28
-28
lines changed

11 files changed

+28
-28
lines changed

pylegend/core/language/pandas_api/pandas_api_groupby_series.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ def raise_exception_if_no_function_applied(self) -> PandasApiAppliedFunctionTdsF
132132
def get_base_frame(self) -> "PandasApiGroupbyTdsFrame":
133133
return self._base_groupby_frame
134134

135-
def get_sub_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
135+
def get_leaf_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
136136
if self.expr is not None:
137-
return self.expr.get_sub_expressions()
137+
return self.expr.get_leaf_expressions()
138138
return [self]
139139

140140
def to_sql_expression(
@@ -192,7 +192,7 @@ def to_pure_query(self, config: FrameToPureConfig = FrameToPureConfig()) -> str:
192192
has_window_func = False
193193
window_expr = ""
194194
function_expr = ""
195-
sub_expressions = self.get_sub_expressions()
195+
sub_expressions = self.get_leaf_expressions()
196196
for expr in sub_expressions:
197197
if isinstance(expr, GroupbySeries):
198198
applied_func = expr.raise_exception_if_no_function_applied().get_applied_function()

pylegend/core/language/pandas_api/pandas_api_series.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ def get_base_frame(self) -> "PandasApiBaseTdsFrame":
135135
def get_filtered_frame(self) -> PandasApiAppliedFunctionTdsFrame:
136136
return self._filtered_frame
137137

138-
def get_sub_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
138+
def get_leaf_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
139139
if self.expr is not None:
140-
return self.expr.get_sub_expressions()
140+
return self.expr.get_leaf_expressions()
141141
return [self]
142142

143143
def to_sql_expression(
@@ -194,7 +194,7 @@ def to_pure_query(self, config: FrameToPureConfig = FrameToPureConfig()) -> str:
194194
has_window_func = False
195195
window_expr = ""
196196
function_expr = ""
197-
sub_expressions = self.get_sub_expressions()
197+
sub_expressions = self.get_leaf_expressions()
198198
for expr in sub_expressions:
199199
if isinstance(expr, Series):
200200
applied_func = expr.get_filtered_frame().get_applied_function()

pylegend/core/language/shared/expression.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,50 +57,50 @@ def is_non_nullable(self) -> bool:
5757
return False
5858

5959
@abstractmethod
60-
def get_sub_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
60+
def get_leaf_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
6161
pass # pragma: no cover
6262

6363

6464
class PyLegendExpressionBooleanReturn(PyLegendExpression, metaclass=ABCMeta):
65-
def get_sub_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
65+
def get_leaf_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
6666
return [self]
6767

6868

6969
class PyLegendExpressionStringReturn(PyLegendExpression, metaclass=ABCMeta):
70-
def get_sub_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
70+
def get_leaf_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
7171
return [self]
7272

7373

7474
class PyLegendExpressionNumberReturn(PyLegendExpression, metaclass=ABCMeta):
75-
def get_sub_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
75+
def get_leaf_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
7676
return [self] # pragma: no cover (Covered by its subclasses)
7777

7878

7979
class PyLegendExpressionIntegerReturn(PyLegendExpressionNumberReturn, metaclass=ABCMeta):
80-
def get_sub_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
80+
def get_leaf_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
8181
return [self]
8282

8383

8484
class PyLegendExpressionFloatReturn(PyLegendExpressionNumberReturn, metaclass=ABCMeta):
85-
def get_sub_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
85+
def get_leaf_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
8686
return [self]
8787

8888

8989
class PyLegendExpressionDateReturn(PyLegendExpression, metaclass=ABCMeta):
90-
def get_sub_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
90+
def get_leaf_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
9191
return [self] # pragma: no cover (Covered by its subclasses)
9292

9393

9494
class PyLegendExpressionDateTimeReturn(PyLegendExpressionDateReturn, metaclass=ABCMeta):
95-
def get_sub_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
95+
def get_leaf_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
9696
return [self]
9797

9898

9999
class PyLegendExpressionStrictDateReturn(PyLegendExpressionDateReturn, metaclass=ABCMeta):
100-
def get_sub_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
100+
def get_leaf_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
101101
return [self]
102102

103103

104104
class PyLegendExpressionNullReturn(PyLegendExpression, metaclass=ABCMeta):
105-
def get_sub_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
105+
def get_leaf_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
106106
return [self]

pylegend/core/language/shared/operations/binary_expression.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ def to_pure_expression(self, config: FrameToPureConfig) -> str:
105105
def is_non_nullable(self) -> bool:
106106
return self.__non_nullable
107107

108-
def get_sub_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
108+
def get_leaf_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
109109
sub_expressions: PyLegendList["PyLegendExpression"] = []
110-
sub_expressions += self.__operand1.get_sub_expressions()
111-
sub_expressions += self.__operand2.get_sub_expressions()
110+
sub_expressions += self.__operand1.get_leaf_expressions()
111+
sub_expressions += self.__operand2.get_leaf_expressions()
112112
return sub_expressions

pylegend/core/language/shared/operations/nary_expression.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ def to_pure_expression(self, config: FrameToPureConfig) -> str:
106106
def is_non_nullable(self) -> bool:
107107
return self.__non_nullable
108108

109-
def get_sub_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
109+
def get_leaf_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
110110
sub_expressions: PyLegendList["PyLegendExpression"] = []
111111
for operand in self.__operands:
112-
sub_expressions += operand.get_sub_expressions()
112+
sub_expressions += operand.get_leaf_expressions()
113113
return sub_expressions

pylegend/core/language/shared/operations/nullary_expression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,5 @@ def to_pure_expression(self, config: FrameToPureConfig) -> str:
7070
def is_non_nullable(self) -> bool:
7171
return self.__non_nullable
7272

73-
def get_sub_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
73+
def get_leaf_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
7474
return [self]

pylegend/core/language/shared/operations/unary_expression.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,5 @@ def to_pure_expression(self, config: FrameToPureConfig) -> str:
8989
def is_non_nullable(self) -> bool:
9090
return self.__non_nullable
9191

92-
def get_sub_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
93-
return self.__operand.get_sub_expressions()
92+
def get_leaf_expressions(self) -> PyLegendSequence["PyLegendExpression"]:
93+
return self.__operand.get_leaf_expressions()

pylegend/core/tds/pandas_api/frames/functions/assign_function.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def to_pure(self, config: FrameToPureConfig) -> str:
139139
for col, func in self.__col_definitions.items():
140140
res = func(tds_row)
141141
if isinstance(res, (Series, GroupbySeries)):
142-
sub_expressions = res.get_sub_expressions()
142+
sub_expressions = res.get_leaf_expressions()
143143
for expr in sub_expressions:
144144
if isinstance(expr, Series):
145145
applied_func = expr.get_filtered_frame().get_applied_function()

pylegend/core/tds/pandas_api/frames/helpers/series_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def assert_and_find_core_series(expr: PyLegendExpression) -> PyLegendOptional[Py
140140

141141
core_series_list: PyLegendList[PyLegendUnion[Series, GroupbySeries]] = []
142142

143-
sub_expressions = expr.get_sub_expressions()
143+
sub_expressions = expr.get_leaf_expressions()
144144
for expr in sub_expressions:
145145
if isinstance(expr, (Series, GroupbySeries)):
146146
core_series_list.append(expr)

tests/core/language/shared/test_variable_expressions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def test_string_variable_expression(self) -> None:
4747
var1 = PyLegendString(PyLegendStringVariableExpression("var1"))
4848
assert var1.to_pure_expression(self.frame_to_pure_config) == '$var1'
4949
assert (var1 + '__').to_pure_expression(self.frame_to_pure_config) == "(toOne($var1) + '__')"
50-
assert var1.value().get_sub_expressions() == [var1.value()]
50+
assert var1.value().get_leaf_expressions() == [var1.value()]
5151

5252
def test_number_variable_expressions(self) -> None:
5353
var1 = PyLegendNumber(PyLegendNumberVariableExpression("var1"))

0 commit comments

Comments
 (0)