Source code for biogeme.expressions.binary_expressions
"""Arithmetic expressions accepted by Biogeme: binary operatorsMichel BierlaireWed Mar 26 09:55:46 2025"""from__future__importannotationsimportloggingfrom.base_expressionsimportExpression,ExpressionOrNumericfrom.convertimportvalidate_and_convertlogger=logging.getLogger(__name__)
[docs]classBinaryOperator(Expression):""" Base class for arithmetic expressions that are binary operators. This expression is the result of the combination of two expressions, typically addition, subtraction, multiplication or division. """def__init__(self,left:ExpressionOrNumeric,right:ExpressionOrNumeric):"""Constructor :param left: first arithmetic expression :type left: biogeme.expressions.Expression :param right: second arithmetic expression :type right: biogeme.expressions.Expression :raise BiogemeError: if one of the expressions is invalid, that is neither a numeric value nor a biogeme.expressions.Expression object. """super().__init__()self.left=validate_and_convert(left)self.right=validate_and_convert(right)self.children.append(self.left)self.children.append(self.right)