aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/kernel_tests/unique_op_test.py
blob: 4d6543a2065d83c25c020d60b877a2030197241d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""Tests for tensorflow.kernels.unique_op."""
import tensorflow.python.platform

import numpy as np
import tensorflow as tf


class UniqueTest(tf.test.TestCase):

  def testInt32(self):
    x = list(np.random.randint(2, high=10, size=7000))
    with self.test_session() as sess:
      y, idx = tf.unique(x)
      tf_y, tf_idx = sess.run([y, idx])

    self.assertEqual(len(x), len(tf_idx))
    self.assertEqual(len(tf_y), len(np.unique(x)))
    for i in range(len(x)):
      self.assertEqual(x[i], tf_y[tf_idx[i]])

if __name__ == "__main__":
  tf.test.main()