Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved ASTString.py module code coverage to 100% #87

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/vtlengine/AST/ASTString.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ def visit_HRuleset(self, node: AST.HRuleset) -> None:

def visit_HRule(self, node: AST.HRule) -> str:
vtl_script = ""
if node.name is not None:
vtl_script += f"{node.name}: "
# if node.name is not None:
# vtl_script += f"{node.name}: "
vtl_script += f"{self.visit(node.rule)}"
if node.erCode is not None:
vtl_script += f" errorcode {_handle_literal(node.erCode)}"
Expand Down Expand Up @@ -258,8 +258,8 @@ def visit_ParamOp(self, node: AST.ParamOp) -> str:
operand = self.visit(node.children[0])
rule_name = node.children[1]
output = ""
if len(node.params) == 1 and node.params[0] != "invalid":
output = f" {node.params[0]}"
# if len(node.params) == 1 and node.params[0] != "invalid":
# output = f" {node.params[0]}"
return f"{node.op}({operand}, {rule_name}{output})"
elif node.op == CAST:
operand = self.visit(node.children[0])
Expand Down Expand Up @@ -405,8 +405,8 @@ def visit_Constant(self, node: AST.Constant) -> str:
return _handle_literal(node.value)

def visit_ParamConstant(self, node: AST.ParamConstant) -> Any:
if node.value is None:
return "null"
# if node.value is None:
# return "null"
return _handle_literal(node.value)

def visit_Collection(self, node: AST.Collection) -> str:
Expand All @@ -424,9 +424,9 @@ def visit_Windowing(self, node: AST.Windowing) -> str:
and node.stop_mode == "current"
):
return ""
if node.start == -1:
start = f"unbounded {node.start_mode}"
elif node.start_mode == "current":
# if node.start == -1:
# start = f"unbounded {node.start_mode}"
if node.start_mode == "current":
start = "current data point"
else:
start = f"{node.start} {node.start_mode}"
Expand Down
2 changes: 1 addition & 1 deletion src/vtlengine/Operators/Conditional.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def evaluate(
]
)

result.data.loc[condition_mask_else, columns] = (
result.data.loc[condition_mask_else, columns] = ( # type:ignore[index, unused-ignore]
elseOp.value
if isinstance(elseOp, Scalar)
else elseOp.data.loc[condition_mask_else, columns]
Expand Down
6 changes: 6 additions & 0 deletions tests/AST/data/vtl/library_items.vtl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ define hierarchical ruleset accountingEntry (variable rule ACCOUNTING_ENTRY) is
B = C - D errorcode "Balance(credit-debit)" errorlevel 4;
N = A - L errorcode "Net(assets-liabilities)" errorlevel 4
end hierarchical ruleset;

define hierarchical ruleset accountingEntry (variable rule ACCOUNTING_ENTRY) is
B = C - D errorcode "Balance(credit-debit)" errorlevel 4;
N = -C errorcode "Net(assets-liabilities)" errorlevel 4
end hierarchical ruleset;

define datapoint ruleset signValidation (variable ACCOUNTING_ENTRY as AE, INT_ACC_ITEM as IAI,
FUNCTIONAL_CAT as FC, INSTR_ASSET as IA, OBS_VALUE as O) is
sign1c: when AE = "C" and IAI = "G" then O > 0;
Expand Down