import tensorflow as tf


constraint['sigmean'] = (5.20, 5.30)
constraint['sigwidth'] = (0.001, 1.)
constraint['argpar'] = (-100., -1.)
constraint['nsig'] = (0., 10000)
constraint['nbkg'] = (0., 10000)
constraint['mes'] = (5.20, 5.30)

# keep a variable dictionary for easy key-based access compatible with constraints
vdict = {}


pi = tf.constant(np.pi, dtype=tf.float64, name="pi")
sqrt2pi = tf.constant(np.sqrt(2 * np.pi), dtype=tf.float64, name="sqrt2pi")
two = tf.constant(2, dtype=tf.float64, name="two")
one = tf.constant(1, dtype=tf.float64, name="one")
zero = tf.constant(0, dtype=tf.float64, name="zero")


def gradsafe_sqrt(x, clip_low=1e-18, name=None):
    with tf.name_scope(name, "gradsafe_sqrt"):
        return tf.sqrt(tf.clip_by_value(x, clip_low, x))


