# Path: ifcb/tests/data/fileset_info.py
# def get_fileset_bin(lid):
#     return _dd()[lid]
# 
# Path: ifcb/viz/utils.py
# def square_letterboxed(img, size=SQUARE_DEFAULT_SIZE, fill_value='median'):
#     if fill_value == 'median':
#         fill_value = int(np.median(img))
#     elif fill_value == 'mean':
#         fill_value = int(np.mean(img))
#     scale = 1.0 * size / max(img.shape)
#     scaled = rescale(img, scale, mode='reflect', preserve_range=True).astype(np.uint8)
#     h, w = scaled.shape
#     ctr = size / 2
#     letterboxed = np.zeros((size, size), dtype=np.uint8) + fill_value
#     y = int(ctr - h/2)
#     x = int(ctr - w/2)
#     letterboxed[y:y+h,x:x+w] = scaled
#     return letterboxed
# 
# def square(img, size=SQUARE_DEFAULT_SIZE):
#     scaled = resize(img, (size, size), mode='reflect', preserve_range=True).astype(np.uint8)
#     return scaled
# 
# SQUARE_DEFAULT_SIZE = 399


import unittest
import numpy as np
from ifcb.tests.data.fileset_info import get_fileset_bin
from ifcb.viz.utils import square_letterboxed, square, SQUARE_DEFAULT_SIZE
        b = get_fileset_bin(SL_BIN_LID)
        self.img = b.images[1]
    def test_square(self):
        sq = square(self.img, size=5)
        assert np.allclose(sq, SQ)
    def test_size(self):
        sq = square(self.img, 20)
        assert sq.shape == (20, 20)
    def test_default_size(self):
        sq = square(self.img)
        assert sq.shape[0] == SQUARE_DEFAULT_SIZE
        assert sq.shape[1] == SQUARE_DEFAULT_SIZE

@unittest.skip('deprecated feature')
class TestSquareLetterboxed(unittest.TestCase):
    def setUp(self):
        b = get_fileset_bin(SL_BIN_LID)
        self.img = b.images[1]
    def test_fill_value_median(self):
        sl = square_letterboxed(self.img, size=5)
        assert np.allclose(sl, SL_MEDIAN)
        sl = square_letterboxed(self.img, size=5, fill_value='median')
        assert np.allclose(sl, SL_MEDIAN)
    def test_fill_value_mean(self):
        sl = square_letterboxed(self.img, size=5, fill_value='mean')
        assert np.allclose(sl, SL_MEAN)
    def test_fill_value_27(self):
        sl = square_letterboxed(self.img, size=5, fill_value=27)
        assert np.allclose(sl, SL_27)
    def test_size(self):

# Path: ifcb/tests/data/fileset_info.py
# def get_fileset_bin(lid):
#     return _dd()[lid]
# 
# Path: ifcb/viz/utils.py
# def square_letterboxed(img, size=SQUARE_DEFAULT_SIZE, fill_value='median'):
#     if fill_value == 'median':
#         fill_value = int(np.median(img))
#     elif fill_value == 'mean':
#         fill_value = int(np.mean(img))
#     scale = 1.0 * size / max(img.shape)
#     scaled = rescale(img, scale, mode='reflect', preserve_range=True).astype(np.uint8)
#     h, w = scaled.shape
#     ctr = size / 2
#     letterboxed = np.zeros((size, size), dtype=np.uint8) + fill_value
#     y = int(ctr - h/2)
#     x = int(ctr - w/2)
#     letterboxed[y:y+h,x:x+w] = scaled
#     return letterboxed
# 
# def square(img, size=SQUARE_DEFAULT_SIZE):
#     scaled = resize(img, (size, size), mode='reflect', preserve_range=True).astype(np.uint8)
#     return scaled
# 
# SQUARE_DEFAULT_SIZE = 399


# Path: ifcb/tests/viz/test_utils.py
import unittest
import numpy as np
from ifcb.tests.data.fileset_info import get_fileset_bin
from ifcb.viz.utils import square_letterboxed, square, SQUARE_DEFAULT_SIZE

        b = get_fileset_bin(SL_BIN_LID)
        self.img = b.images[1]
    def test_square(self):
        sq = square(self.img, size=5)
        assert np.allclose(sq, SQ)
    def test_size(self):
        sq = square(self.img, 20)
        assert sq.shape == (20, 20)
    def test_default_size(self):
        sq = square(self.img)
        assert sq.shape[0] == SQUARE_DEFAULT_SIZE
        assert sq.shape[1] == SQUARE_DEFAULT_SIZE

@unittest.skip('deprecated feature')
class TestSquareLetterboxed(unittest.TestCase):
    def setUp(self):
        b = get_fileset_bin(SL_BIN_LID)
        self.img = b.images[1]
    def test_fill_value_median(self):
        sl = square_letterboxed(self.img, size=5)
        assert np.allclose(sl, SL_MEDIAN)
        sl = square_letterboxed(self.img, size=5, fill_value='median')
        assert np.allclose(sl, SL_MEDIAN)
    def test_fill_value_mean(self):
        sl = square_letterboxed(self.img, size=5, fill_value='mean')
        assert np.allclose(sl, SL_MEAN)
    def test_fill_value_27(self):
        sl = square_letterboxed(self.img, size=5, fill_value=27)
        assert np.allclose(sl, SL_27)
    def test_size(self):

        sl = square_letterboxed(self.img, size=20)