# Path: dynts/api/timeseries.py
# def ts_bin_op(op_name, ts1, ts2, all=True, fill=None, name=None):
#     '''Entry point for any arithmetic type function performed on a timeseries
#     and/or a scalar.
#     op_name - name of the function to be performed
#     ts1, ts2 - timeseries or scalars that the function is to performed over
#     all - whether all dates should be included in the result
#     fill - the value that should be used to represent "missing values"
#     name - the name of the resulting time series
#     '''
#     op = op_get(op_name)
#     fill = fill if fill is not None else settings.missing_value
#     if hasattr(fill, '__call__'):
#         fill_fn = fill
#     else:
#         fill_fn = lambda: fill
# 
#     name = name or '%s(%s,%s)' % (op_name, ts1, ts2)
#     if is_timeseries(ts1):
#         ts = ts1
#         if is_timeseries(ts2):
#             dts, data = op_ts_ts(op_name, op, ts1, ts2, all, fill_fn)
# 
#         else:
#             dts, data = op_ts_scalar(op_name, op, ts1, ts2, fill_fn)
#     else:
#         if is_timeseries(ts2):
#             ts = ts2
#             dts, data = op_scalar_ts(op_name, op, ts1, ts2, fill_fn)
#         else:
#             return op(ts1, ts2)
# 
#     return ts.clone(date=dts, data=data, name=name)
# 
# Path: dynts/dsl/ast/base.py
# class BinOp(ConcatOp):
# 
#     def __init__(self, left, right, op):
#         if op in settings.special_operators:
#             raise ValueError('not a valid binary operator: %s' % op)
#         super().__init__(left, right, op, concatenate=False)
#         self.append = None
# 
#     @property
#     def left(self):
#         return self[0]
# 
#     @property
#     def right(self):
#         return self[1]
# 
# class Number(BaseExpression):
#     '''
#     A simple number.
#     This expression is a constant numeric value
#     '''
#     def _unwind(self, values, backend, **kwargs):
#         return self.value


from ...api.timeseries import ts_bin_op
from .base import BinOp, Number



class BinMathOp(BinOp):

    def __init__(self, left, right, op, op_name):
        self.op_name = op_name
        super().__init__(left, right, op)

    def _unwind(self, values, backend, full=False, **kwargs):
        le = self.left.unwind(values, backend, **kwargs)
        ri = self.right.unwind(values, backend, **kwargs)
        return ts_bin_op(self.op_name, le, ri, name=str(self))

    def lineardecomp(self):
        if isinstance(self.left, Number):

# Path: dynts/api/timeseries.py
# def ts_bin_op(op_name, ts1, ts2, all=True, fill=None, name=None):
#     '''Entry point for any arithmetic type function performed on a timeseries
#     and/or a scalar.
#     op_name - name of the function to be performed
#     ts1, ts2 - timeseries or scalars that the function is to performed over
#     all - whether all dates should be included in the result
#     fill - the value that should be used to represent "missing values"
#     name - the name of the resulting time series
#     '''
#     op = op_get(op_name)
#     fill = fill if fill is not None else settings.missing_value
#     if hasattr(fill, '__call__'):
#         fill_fn = fill
#     else:
#         fill_fn = lambda: fill
# 
#     name = name or '%s(%s,%s)' % (op_name, ts1, ts2)
#     if is_timeseries(ts1):
#         ts = ts1
#         if is_timeseries(ts2):
#             dts, data = op_ts_ts(op_name, op, ts1, ts2, all, fill_fn)
# 
#         else:
#             dts, data = op_ts_scalar(op_name, op, ts1, ts2, fill_fn)
#     else:
#         if is_timeseries(ts2):
#             ts = ts2
#             dts, data = op_scalar_ts(op_name, op, ts1, ts2, fill_fn)
#         else:
#             return op(ts1, ts2)
# 
#     return ts.clone(date=dts, data=data, name=name)
# 
# Path: dynts/dsl/ast/base.py
# class BinOp(ConcatOp):
# 
#     def __init__(self, left, right, op):
#         if op in settings.special_operators:
#             raise ValueError('not a valid binary operator: %s' % op)
#         super().__init__(left, right, op, concatenate=False)
#         self.append = None
# 
#     @property
#     def left(self):
#         return self[0]
# 
#     @property
#     def right(self):
#         return self[1]
# 
# class Number(BaseExpression):
#     '''
#     A simple number.
#     This expression is a constant numeric value
#     '''
#     def _unwind(self, values, backend, **kwargs):
#         return self.value


# Path: dynts/dsl/ast/binmath.py
from ...api.timeseries import ts_bin_op
from .base import BinOp, Number



class BinMathOp(BinOp):

    def __init__(self, left, right, op, op_name):
        self.op_name = op_name
        super().__init__(left, right, op)

    def _unwind(self, values, backend, full=False, **kwargs):
        le = self.left.unwind(values, backend, **kwargs)
        ri = self.right.unwind(values, backend, **kwargs)
        return ts_bin_op(self.op_name, le, ri, name=str(self))

    def lineardecomp(self):
        if isinstance(self.left, Number):

            if isinstance(self.right, Number):
