# Path: tests/context.py



import pprint
import numpy as np
import copy
import pdb
from .context import PROP_MC, PROP_MM

    return xtrue, x, y

class bcolors:
    HEADER = '\033[95m'
    OKBLUE = '\033[94m'
    OKGREEN = '\033[92m'
    WARNING = '\033[93m'
    FAIL = '\033[91m'
    ENDC = '\033[0m'
    BOLD = '\033[1m'
    UNDERLINE = '\033[4m'


def print_message(message_str, computed, numerical):
    diff = (computed - numerical) / numerical
    if np.abs(diff) < 1e-4 or ((np.isinf(diff) or np.isnan(diff) or (np.abs(diff) <= 1.1 and np.abs(diff) > 1e-4)) and np.abs(numerical) < 1e-4):
        pass
    else:
        print(bcolors.FAIL + '%s, computed=%.5f, numerical=%.5f, rel. diff=%.5f' % (message_str, computed, numerical, diff) + bcolors.ENDC)

def check_grad(params, model, stochastic=False, alpha=0.5, stoc_seed=42, prop_mode=PROP_MM):
    if stochastic:
        if hasattr(model, 'M'):
            N = model.M
        else:
            N = int(np.ceil(model.N/3.0))
    else:
        N = model.N
    eps = 1e-5

# Path: tests/context.py



# Path: tests/test_utils.py
import pprint
import numpy as np
import copy
import pdb
from .context import PROP_MC, PROP_MM


    return xtrue, x, y

class bcolors:
    HEADER = '\033[95m'
    OKBLUE = '\033[94m'
    OKGREEN = '\033[92m'
    WARNING = '\033[93m'
    FAIL = '\033[91m'
    ENDC = '\033[0m'
    BOLD = '\033[1m'
    UNDERLINE = '\033[4m'


def print_message(message_str, computed, numerical):
    diff = (computed - numerical) / numerical
    if np.abs(diff) < 1e-4 or ((np.isinf(diff) or np.isnan(diff) or (np.abs(diff) <= 1.1 and np.abs(diff) > 1e-4)) and np.abs(numerical) < 1e-4):
        pass
    else:
        print(bcolors.FAIL + '%s, computed=%.5f, numerical=%.5f, rel. diff=%.5f' % (message_str, computed, numerical, diff) + bcolors.ENDC)

def check_grad(params, model, stochastic=False, alpha=0.5, stoc_seed=42, prop_mode=PROP_MM):
    if stochastic:
        if hasattr(model, 'M'):
            N = model.M
        else:
            N = int(np.ceil(model.N/3.0))
    else:
        N = model.N
    eps = 1e-5

    fixed_seed = stochastic or prop_mode == PROP_MC