# Path: sfc_models/utils.py
# class LogicError(ValueError):
#     """
#     Throw this when code logic is broken.
#     """
#     pass
# 
# def replace_token_from_lookup(s, lookup):
#     """
#     Replace tokens using a lookup dictionary.
# 
#     >>> replace_token_from_lookup('y = x', {'y': 'H_y', 'x': 'H_x'})
#     'H_y =H_x '
# 
#     :param s: str
#     :param lookup: dict
#     :return: str
#     """
#     result = []
#     if is_python_3:
#         g = tokenize.tokenize(BytesIO(s.encode('utf-8')).readline)  # tokenize the string
#         for toknum, tokval, _, _, _ in g:
#             if toknum == NAME and tokval in lookup:  # replace NAME tokens
#                 result.append((NAME, lookup[tokval]))
#             else:
#                 result.append((toknum, tokval))
#         return untokenize(result).decode('utf-8')
#     else:  # pragma: no cover   [Do my coverage on Python 3]
#         g = tokenize.generate_tokens(BytesIO(s.encode('utf-8')).readline)  # tokenize the string
#         for toknum, tokval, _, _, _ in g:
#             if toknum == NAME and tokval in lookup:  # replace NAME tokens
#                 result.append((NAME, lookup[tokval]))
#             else:
#                 result.append((toknum, tokval))
#         return str(untokenize(result).decode('utf-8'))


import sys
import tokenize
import copy
from io import BytesIO
    from tokenize import untokenize, NAME, ENDMARKER, ENCODING, OP, NEWLINE, NUMBER
    from tokenize import untokenize, NAME, ENDMARKER, OP
from sfc_models.utils import LogicError, replace_token_from_lookup
        """
        Returns the string representation of the right hand side.
        :return: str
        """
        out = [str(s) for s in self.TermList]
        out = ''.join(out)
        if out.startswith('+'):
            out = out[1:]
        # If we have no terms, we are equal to zero.
        # This also happens if terms have a Constant = 0
        if out == '':
            out = '0.0'
        return out

    def RHS(self):
        """
        Convenience alias for GetRightHandSide()
        :return: str
        """
        return self.GetRightHandSide()

    def AddTerm(self, term):
        """
        Add a term to the equation. May be a string or Term object.
        :param term: Term
        :return: None
        """
        term = Term(term)
        if len(self.TermList) > 0:
            if term.IsBlob:

# Path: sfc_models/utils.py
# class LogicError(ValueError):
#     """
#     Throw this when code logic is broken.
#     """
#     pass
# 
# def replace_token_from_lookup(s, lookup):
#     """
#     Replace tokens using a lookup dictionary.
# 
#     >>> replace_token_from_lookup('y = x', {'y': 'H_y', 'x': 'H_x'})
#     'H_y =H_x '
# 
#     :param s: str
#     :param lookup: dict
#     :return: str
#     """
#     result = []
#     if is_python_3:
#         g = tokenize.tokenize(BytesIO(s.encode('utf-8')).readline)  # tokenize the string
#         for toknum, tokval, _, _, _ in g:
#             if toknum == NAME and tokval in lookup:  # replace NAME tokens
#                 result.append((NAME, lookup[tokval]))
#             else:
#                 result.append((toknum, tokval))
#         return untokenize(result).decode('utf-8')
#     else:  # pragma: no cover   [Do my coverage on Python 3]
#         g = tokenize.generate_tokens(BytesIO(s.encode('utf-8')).readline)  # tokenize the string
#         for toknum, tokval, _, _, _ in g:
#             if toknum == NAME and tokval in lookup:  # replace NAME tokens
#                 result.append((NAME, lookup[tokval]))
#             else:
#                 result.append((toknum, tokval))
#         return str(untokenize(result).decode('utf-8'))


# Path: sfc_models/equation.py
import sys
import tokenize
import copy
from io import BytesIO
    from tokenize import untokenize, NAME, ENDMARKER, ENCODING, OP, NEWLINE, NUMBER
    from tokenize import untokenize, NAME, ENDMARKER, OP
from sfc_models.utils import LogicError, replace_token_from_lookup

        """
        Returns the string representation of the right hand side.
        :return: str
        """
        out = [str(s) for s in self.TermList]
        out = ''.join(out)
        if out.startswith('+'):
            out = out[1:]
        # If we have no terms, we are equal to zero.
        # This also happens if terms have a Constant = 0
        if out == '':
            out = '0.0'
        return out

    def RHS(self):
        """
        Convenience alias for GetRightHandSide()
        :return: str
        """
        return self.GetRightHandSide()

    def AddTerm(self, term):
        """
        Add a term to the equation. May be a string or Term object.
        :param term: Term
        :return: None
        """
        term = Term(term)
        if len(self.TermList) > 0:
            if term.IsBlob:

                raise LogicError('Cannot add a blob to non-empty equation')