Skip to content

Implement Max operator#116

Closed
killian-scalian wants to merge 15 commits intomainfrom
contrib_max
Closed

Implement Max operator#116
killian-scalian wants to merge 15 commits intomainfrom
contrib_max

Conversation

@killian-scalian
Copy link
Copy Markdown
Collaborator

No description provided.

@killian-scalian killian-scalian marked this pull request as ready for review August 1, 2025 16:13
@killian-scalian killian-scalian requested a review from tbittar August 1, 2025 16:13
Comment thread grammar/Expr.g4 Outdated
| IDENTIFIER '[' expr ']' # timeIndex
| '(' expr ')' '[' shift ']' # timeShiftExpr
| '(' expr ')' '[' expr ']' # timeIndexExpr
| 'max' '(' expr (',' expr)* ')' # maxExpr
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be MAX here, no ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends, we want MAX or max as operand?

Comment thread src/gems/expression/copy.py Outdated

@dataclass(frozen=True)
class CopyVisitor(ExpressionVisitorOperations[ExpressionNode]):
class CopyVisitor(ExpressionVisitorOperations[ExpressionNode]): # type: ignore
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need #type : ignore ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it depends with what ExpressionVisitorOperations returns. If it returns ExpressionNode, it is ok, if it returns T, we need to ignore

def port_field_aggregator(self, node: PortFieldAggregatorNode) -> float:
raise NotImplementedError()

def max_node(self, node: MaxNode) -> float: # type: ignore
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need type : ignore ?

Comment thread src/gems/expression/visitor.py Outdated
"""
import typing

from typing import cast
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is it used for ?

return left_value / right_value

def max_node(self, node: MaxNode) -> ExpressionNode: # type: ignore
return MaxNode(operands=[visit(op, self) for op in node.operands]) # type: ignore
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again why type: ignore ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it returns ExpressionNode, wich is not homogene with ExpressionVisitor abstract method and the visit method

Comment thread tests/unittests/expressions/visitor/test_linearization.py Outdated
Comment thread tests/unittests/expressions/visitor/test_max_expression_checker.py Outdated
@AntaresSimulatorTeam AntaresSimulatorTeam deleted a comment from wiiisp Aug 5, 2025
@aoustry aoustry closed this Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants