# Path: ldif/util/math_util.py
# def int_log2(i):
# def nonzero_mean(tensor):
# def increase_frequency(t, out_dim, flatten=False, interleave=True):


import numpy as np
import tensorflow as tf
from parameterized import parameterized
from ldif.util import math_util
        [0.715278, -0.69884, -0.99973, -0.0232457, 0.0464788, -0.998919]
    ]
    # pylint:enable=bad-whitespace
    expected = np.array(expected, dtype=np.float32)
    if flatten:
      expected = np.reshape(expected, [-1])
    y = math_util.increase_frequency(
        tf.constant(x, dtype=tf.float32), dim, flatten=flatten, interleave=True)
    with self.session() as sess:
      out = sess.run(y)
    distance = float(np.sum(np.abs(expected - out)))
    self.assertLess(distance, FLOAT_DISTANCE_EPS,
                    f'Expected {expected} but got {out}')

  @parameterized.expand([('no_flatten', False),
                         ('flatten', True)])
  def test_increase_frequency_no_interleave(self, name, flatten):
    tf.disable_eager_execution()
    x = np.array([1.0, 0.1123, 0.7463], dtype=np.float32)
    dim = 3
    # pylint:disable=bad-whitespace
    expected = [
        [0,         0,        0,         -1,        1,          1],
        [0.345528,  0.648492, 0.987292,   0.938409, 0.761221,   0.158916],
        [0.715278, -0.99973,  0.0464788, -0.69884, -0.0232457, -0.998919],
    ]
    # pylint:enable=bad-whitespace
    expected = np.array(expected, dtype=np.float32)
    if flatten:
      expected = np.reshape(expected, [-1])

# Path: ldif/util/math_util.py
# def int_log2(i):
# def nonzero_mean(tensor):
# def increase_frequency(t, out_dim, flatten=False, interleave=True):


# Path: ldif/util/math_util_test.py
import numpy as np
import tensorflow as tf
from parameterized import parameterized
from ldif.util import math_util

        [0.715278, -0.69884, -0.99973, -0.0232457, 0.0464788, -0.998919]
    ]
    # pylint:enable=bad-whitespace
    expected = np.array(expected, dtype=np.float32)
    if flatten:
      expected = np.reshape(expected, [-1])
    y = math_util.increase_frequency(
        tf.constant(x, dtype=tf.float32), dim, flatten=flatten, interleave=True)
    with self.session() as sess:
      out = sess.run(y)
    distance = float(np.sum(np.abs(expected - out)))
    self.assertLess(distance, FLOAT_DISTANCE_EPS,
                    f'Expected {expected} but got {out}')

  @parameterized.expand([('no_flatten', False),
                         ('flatten', True)])
  def test_increase_frequency_no_interleave(self, name, flatten):
    tf.disable_eager_execution()
    x = np.array([1.0, 0.1123, 0.7463], dtype=np.float32)
    dim = 3
    # pylint:disable=bad-whitespace
    expected = [
        [0,         0,        0,         -1,        1,          1],
        [0.345528,  0.648492, 0.987292,   0.938409, 0.761221,   0.158916],
        [0.715278, -0.99973,  0.0464788, -0.69884, -0.0232457, -0.998919],
    ]
    # pylint:enable=bad-whitespace
    expected = np.array(expected, dtype=np.float32)
    if flatten:
      expected = np.reshape(expected, [-1])

    y = math_util.increase_frequency(