'Tests that named constructor gives working target assigners.
TODO: Make this test more general.'

def test_create_target_assigner(self):

    corners = [[0.0, 0.0, 1.0, 1.0]]
    groundtruth = box_list.BoxList(tf.constant(corners))
    priors = box_list.BoxList(tf.constant(corners))
    prior_stddevs = tf.constant([[1.0, 1.0, 1.0, 1.0]])
    priors.add_field('stddev', prior_stddevs)
    multibox_ta = targetassigner.create_target_assigner('Multibox', stage='proposal')
    multibox_ta.assign(priors, groundtruth)
    anchors = box_list.BoxList(tf.constant(corners))
    faster_rcnn_proposals_ta = targetassigner.create_target_assigner('FasterRCNN', stage='proposal')
    faster_rcnn_proposals_ta.assign(anchors, groundtruth)
    fast_rcnn_ta = targetassigner.create_target_assigner('FastRCNN')
    fast_rcnn_ta.assign(anchors, groundtruth)
    faster_rcnn_detection_ta = targetassigner.create_target_assigner('FasterRCNN', stage='detection')
    faster_rcnn_detection_ta.assign(anchors, groundtruth)
    with self.assertRaises(ValueError):
        targetassigner.create_target_assigner('InvalidDetector', stage='invalid_stage')
