@parameterized.parameters((False,), (True,))
def test_coordinates_to_heatmap(self, sparse):
    if (not hasattr(tf, 'tensor_scatter_nd_max')):
        self.skipTest('Cannot test function due to old TF version.')

    def graph_fn():
        (y_grid, x_grid) = ta_utils.image_shape_to_grids(height=3, width=5)
        y_coordinates = tf.constant([1.5, 0.5], dtype=tf.float32)
        x_coordinates = tf.constant([2.5, 4.5], dtype=tf.float32)
        sigma = tf.constant([0.1, 0.5], dtype=tf.float32)
        channel_onehot = tf.constant([[1, 0, 0], [0, 1, 0]], dtype=tf.float32)
        channel_weights = tf.constant([1, 1], dtype=tf.float32)
        heatmap = ta_utils.coordinates_to_heatmap(y_grid, x_grid, y_coordinates, x_coordinates, sigma, channel_onehot, channel_weights, sparse=sparse)
        return heatmap
    heatmap = self.execute(graph_fn, [])
    self.assertAlmostEqual(1.0, heatmap[(1, 2, 0)])
    self.assertAlmostEqual(1.0, heatmap[(0, 4, 1)])
@parameterized.parameters((False,), (True,))
def test_coordinates_to_heatmap(self, sparse):
    if (not hasattr(tf, 'tensor_scatter_nd_max')):
        self.skipTest('Cannot test function due to old TF version.')

    def graph_fn():
        (y_grid, x_grid) = ta_utils.image_shape_to_grids(height=3, width=5)
        y_coordinates = tf.constant([1.5, 0.5], dtype=tf.float32)
        x_coordinates = tf.constant([2.5, 4.5], dtype=tf.float32)
        sigma = tf.constant([0.1, 0.5], dtype=tf.float32)
        channel_onehot = tf.constant([[1, 0, 0], [0, 1, 0]], dtype=tf.float32)
        channel_weights = tf.constant([1, 1], dtype=tf.float32)
        heatmap = ta_utils.coordinates_to_heatmap(y_grid, x_grid, y_coordinates, x_coordinates, sigma, channel_onehot, channel_weights, sparse=sparse)
        return heatmap
    heatmap = self.execute(graph_fn, [])
    self.assertAlmostEqual(1.0, heatmap[(1, 2, 0)])
    self.assertAlmostEqual(1.0, heatmap[(0, 4, 1)])