# Path: ldif/util/image_util.py
# def rgba_to_rgb(model_config, rgba):
# def downsample(images, exp=1):
# def get_border_pixels(gt, threshold=0.1):
# def hessian(sdf_im):
# def summarize_image(gt, pred, name):
# def get_pil_formatted_image(image):
# def images_are_near(baseline_image,
#                     result_image,
#                     max_outlier_fraction=0.005,
#                     pixel_error_threshold=0.04):
# def expect_images_are_near_and_save_comparison(test,
#                                                baseline_image,
#                                                result_image,
#                                                comparison_name,
#                                                images_differ_message,
#                                                max_outlier_fraction=0.005,
#                                                pixel_error_threshold=0.04,
#                                                save_format='.png'):
# def expect_image_file_and_image_are_near(test,
#                                          baseline_path,
#                                          result_image_bytes_or_numpy,
#                                          comparison_name,
#                                          images_differ_message,
#                                          max_outlier_fraction=0.005,
#                                          pixel_error_threshold=0.04,
#                                          resize_baseline_image=None):
# 
# Path: ldif/util/line_util.py
# def line_to_image(line_parameters, height, width, falloff=2.0):
# def fractional_vector_projection(e0, e1, p, falloff=2.0):
# def rotate_about_point(angle_of_rotation, point, to_rotate):
# def union_of_line_drawings(lines):
# def network_line_parameters_to_line(line_parameters, height, width):
# 
# Path: ldif/util/path_util.py
# def get_path_to_ldif_root():
# def get_path_to_ldif_parent():
# def package_to_abs(path):
# def gaps_path():
# def test_data_path():
# def util_test_data_path():
# def create_test_output_dir():


import os
import tensorflow as tf
from ldif.util import image_util
from ldif.util import line_util
from ldif.util import path_util
    line_parameters = tf.constant([0.0, 64.0, 64.0, 32.0, 32.0],
                                  dtype=tf.float32)
    image = line_util.line_to_image(
        line_parameters, height=128, width=128, falloff=None)
    target_image_name = 'Centered_Square_0.png'
    baseline_image_path = os.path.join(self.test_data_directory,
                                       target_image_name)
    with self.test_session() as sess:
      image = image_util.get_pil_formatted_image(sess.run(image))
      image_util.expect_image_file_and_image_are_near(
          self, baseline_image_path, image, target_image_name,
          '%s does not match.' % target_image_name)

  def test_render_vertical_rectangle(self):
    line_parameters = tf.constant([0.0, 64.0, 64.0, 16.0, 48.0],
                                  dtype=tf.float32)
    image = line_util.line_to_image(
        line_parameters, height=128, width=128, falloff=None)
    target_image_name = 'Centered_Vertical_Rectangle_0.png'
    baseline_image_path = os.path.join(self.test_data_directory,
                                       target_image_name)
    with self.test_session() as sess:
      image = image_util.get_pil_formatted_image(sess.run(image))
      image_util.expect_image_file_and_image_are_near(
          self, baseline_image_path, image, target_image_name,
          '%s does not match.' % target_image_name)

  def test_render_offset_vertical_rectangle(self):
    line_parameters = tf.constant([0.0, 80.0, 49.0, 16.0, 48.0],
                                  dtype=tf.float32)

# Path: ldif/util/image_util.py
# def rgba_to_rgb(model_config, rgba):
# def downsample(images, exp=1):
# def get_border_pixels(gt, threshold=0.1):
# def hessian(sdf_im):
# def summarize_image(gt, pred, name):
# def get_pil_formatted_image(image):
# def images_are_near(baseline_image,
#                     result_image,
#                     max_outlier_fraction=0.005,
#                     pixel_error_threshold=0.04):
# def expect_images_are_near_and_save_comparison(test,
#                                                baseline_image,
#                                                result_image,
#                                                comparison_name,
#                                                images_differ_message,
#                                                max_outlier_fraction=0.005,
#                                                pixel_error_threshold=0.04,
#                                                save_format='.png'):
# def expect_image_file_and_image_are_near(test,
#                                          baseline_path,
#                                          result_image_bytes_or_numpy,
#                                          comparison_name,
#                                          images_differ_message,
#                                          max_outlier_fraction=0.005,
#                                          pixel_error_threshold=0.04,
#                                          resize_baseline_image=None):
# 
# Path: ldif/util/line_util.py
# def line_to_image(line_parameters, height, width, falloff=2.0):
# def fractional_vector_projection(e0, e1, p, falloff=2.0):
# def rotate_about_point(angle_of_rotation, point, to_rotate):
# def union_of_line_drawings(lines):
# def network_line_parameters_to_line(line_parameters, height, width):
# 
# Path: ldif/util/path_util.py
# def get_path_to_ldif_root():
# def get_path_to_ldif_parent():
# def package_to_abs(path):
# def gaps_path():
# def test_data_path():
# def util_test_data_path():
# def create_test_output_dir():


# Path: ldif/model/model_test.py
import os
import tensorflow as tf
from ldif.util import image_util
from ldif.util import line_util
from ldif.util import path_util

    line_parameters = tf.constant([0.0, 64.0, 64.0, 32.0, 32.0],
                                  dtype=tf.float32)
    image = line_util.line_to_image(
        line_parameters, height=128, width=128, falloff=None)
    target_image_name = 'Centered_Square_0.png'
    baseline_image_path = os.path.join(self.test_data_directory,
                                       target_image_name)
    with self.test_session() as sess:
      image = image_util.get_pil_formatted_image(sess.run(image))
      image_util.expect_image_file_and_image_are_near(
          self, baseline_image_path, image, target_image_name,
          '%s does not match.' % target_image_name)

  def test_render_vertical_rectangle(self):
    line_parameters = tf.constant([0.0, 64.0, 64.0, 16.0, 48.0],
                                  dtype=tf.float32)
    image = line_util.line_to_image(
        line_parameters, height=128, width=128, falloff=None)
    target_image_name = 'Centered_Vertical_Rectangle_0.png'
    baseline_image_path = os.path.join(self.test_data_directory,
                                       target_image_name)
    with self.test_session() as sess:
      image = image_util.get_pil_formatted_image(sess.run(image))
      image_util.expect_image_file_and_image_are_near(
          self, baseline_image_path, image, target_image_name,
          '%s does not match.' % target_image_name)

  def test_render_offset_vertical_rectangle(self):
    line_parameters = tf.constant([0.0, 80.0, 49.0, 16.0, 48.0],
                                  dtype=tf.float32)

    image = line_util.line_to_image(