import tensorflow as tf

class RefineLabeledTensorOp(tf.test.TestCase):
    def runTest(self):
        members = set(dir(self.__class__)) - set(dir(tf.test.TestCase))
        members.remove('runTest')
        rList = []
        for mem in members:
            rList.append(eval('self.' + mem + '()'))
        return rList
    def stringAndFloatTest(self):
        print "stringAndFloatTest"
        ts1 = tf.constant(["ab", "c", "d"])
        ts2 = tf.constant(["a","b","c","e" ])
        ts3 = tf.constant([ "a","ab", "b","c","d","e"])

        d1 = tf.constant([ [ [1.0, 2.0],[3.0, 4.0] ], [ [5.0, 6.0],[7.0, 8.0] ] ,[ [9.0, 10.0], [11.0,12.0] ] ])

        ts3 = tf.user_ops.join_labels([ts1, ts2])
        d2 = tf.user_ops.refine_labeled_tensor(d1, ts1, ts3, 0)


        with tf.Session() as sess:
            print sess.run(d2)

    def uint8andint64Test(self):
        print "uint8andint64Test"
        ts1 = tf.constant([2, 4, 5])
        ts2 = tf.constant([1,3,4,6 ])
        ts3 = tf.constant([ 1,2,3,4,5,6])

        d1 = tf.constant([ [ [1.0, 2.0],[3.0, 4.0] ], [ [5.0, 6.0],[7.0, 8.0] ] ,[ [9.0, 10.0], [11.0,12.0] ] ])

        ts3 = tf.cast(ts3, tf.uint8)
        ts3 = tf.cast(ts3, tf.uint8)
        d1 = tf.cast(d1, tf.int64)

        ts3 = tf.user_ops.join_labels([ts1, ts2])
        d2 = tf.user_ops.refine_labeled_tensor(d1, ts1, ts3, 0)


        with tf.Session() as sess:
            print sess.run(d2)

    def uint8andint64Test(self):
        print "uint8andint64Test"
        ts1 = tf.constant([2, 4, 5])
        ts2 = tf.constant([1,3,4,6 ])
        ts3 = tf.constant([ 1,2,3,4,5,6])

        d1 = tf.constant([ [ [1.0, 2.0],[3.0, 4.0] ], [ [5.0, 6.0],[7.0, 8.0] ] ,[ [9.0, 10.0], [11.0,12.0] ] ])

        ts3 = tf.cast(ts3, tf.uint8)
        ts3 = tf.cast(ts3, tf.uint8)
        d1 = tf.cast(d1, tf.int64)

        ts3 = tf.user_ops.join_labels([ts1, ts2])
        d2 = tf.user_ops.refine_labeled_tensor(d1, ts1, ts3, 0)


        with tf.Session() as sess:
            print sess.run(d2)


if __name__ == "__main__":
    test = RefineLabeledTensorOp()
    testList = test.runTest()
