def check_fourier_cond_init()

in src/evaluator.py [0:0]


def check_fourier_cond_init(env, src, tgt, hyp):

    try:
        nx = src
        dimension, pos = env.parse_int(nx)
        nx = nx[pos:]
        operateur, nx = env.prefix_to_infix(nx[1:])
        cond_init, nx = env.prefix_to_infix(nx[1:])
        if nx[1:] != []:
            logger.info("wrong src")
            return False

        # read tgt
        reg, pos1 = env.parse_int(tgt)
        stab, pos2 = env.parse_int(tgt[pos1 + 1 :])
        tgt = tgt[pos1 + pos2 :]

        # read hyp
        reghyp, pos1 = env.parse_int(hyp)
        stabhyp, pos2 = env.parse_int(hyp[pos1 + 1 :])
        hyp = hyp[pos1 + pos2 :]

        # compare hyp and tgt
        if (
            reghyp != reg or stabhyp != stab
        ):  # First condition on existence and stability
            # logger.error("Incorrect reg or stab")
            return False

        # predict bounds is a subtask, used for training but not for evaluation,
        # hence the comment, uncomment if bounds are to be used at evaluations
        # if env.predict_bounds:

        #     # read tgt
        #     nr_bounds = tgt.count(env.list_separator)
        #     nr_dimension = tgt.count(env.line_separator)
        #     if nr_bounds != dimension or nr_dimension != dimension:
        #         # logger.error("Incorrect form of tgt in read_fourier")
        #         return False
        #     bounds = []
        #     pos = 1
        #     for i in range(dimension):
        #         tgt = tgt[pos + 1:]
        #         if tgt[0] == env.pos_inf:
        #             bda = np.inf
        #             pos = 1
        #         elif tgt[0] == env.neg_inf:
        #             bda = -np.inf
        #             pos = 1
        #         else:
        #             bda, pos = env.parse_float(tgt)
        #         tgt = tgt[pos + 1:]
        #         if tgt[0] == env.pos_inf:
        #             bdb = np.inf
        #             pos = 1
        #         elif tgt[0] == env.neg_inf:
        #             bdb = -np.inf
        #             pos = 1
        #         else:
        #             bdb, pos = env.parse_float(tgt)
        #         bounds.append([bda, bdb])

        #     # read hyp
        #     nr_bounds = hyp.count(env.list_separator)
        #     nr_dimension = hyp.count(env.line_separator)
        #     if nr_bounds != dimension or nr_dimension != dimension:
        #         # logger.error("Incorrect form of hyp in read_fourier")
        #         return False
        #     bounds_hyp = []
        #     pos = 1
        #     for i in range(dimension):
        #         hyp = hyp[pos + 1:]
        #         if hyp[0] == env.pos_inf:
        #             bda = np.inf
        #             pos = 1
        #         elif hyp[0] == env.neg_inf:
        #             bda = -np.inf
        #             pos = 1
        #         else:
        #             bda, pos = env.parse_float(hyp)
        #         hyp = hyp[pos + 1:]
        #         if hyp[0] == env.pos_inf:
        #             bdb = np.inf
        #             pos = 1
        #         elif hyp[0] == env.neg_inf:
        #             bdb = -np.inf
        #             pos = 1
        #         else:
        #             bdb, pos = env.parse_float(hyp)
        #         bounds_hyp.append([bda, bdb])

        #     # compare hyp and tgt
        #     for i in range(len(bounds)):
        # # Second condition on frequency bounds of initial condition
        #         for j in range(len(bounds[i])):
        #             if abs(bounds[i][j]) == np.inf:
        #                 if bounds[i][j] != bounds_hyp[i][j]:
        #                     # logger.error("Incorrect inf bound prediction")
        #                     return False
        #             elif abs(bounds[i][j]) == 0:
        #                 if bounds_hyp[i][j] != 0:
        #                     # logger.error("Incorrect 0 bound prediction")
        #                     return False
        #             else:
        #                 if (bounds[i][j] - bounds_hyp[i][j]) / bounds[i][j] > 0.1:
        #                     # logger.error("Incorrect bound prediction")
        #                     return False

    except Exception as e:
        logger.info(f"Exception {e} in top_test")
        return False

    return True