# Path: labella/scale.py
# class LinearScale(object):
#     def __init__(
#         self, domain=None, _range=None, interpolate=None, clamp=False
#     ):
#         self._domain = [0, 1] if domain is None else domain
#         self._range = [0, 1] if _range is None else _range
#         self._interpolate = (
#             d3_interpolate if interpolate is None else interpolate
#         )
#         self._clamp = clamp
# 
#         self._output = None
#         self._input = None
#         self.rescale()
# 
#     def rescale(self):
#         linear = d3_scale_bilinear
#         if self._clamp:
#             uninterpolate = d3_uninterpolateClamp
#         else:
#             uninterpolate = d3_uninterpolateNumber
#         self._output = linear(
#             self._domain, self._range, uninterpolate, self._interpolate
#         )
#         self._input = linear(
#             self._range, self._domain, uninterpolate, d3_interpolate
#         )
#         return self
# 
#     def scale(self, x):
#         return self._output(x)
# 
#     def invert(self, y):
#         return self._input(y)
# 
#     def domain(self, x=None):
#         if x is None:
#             return self._domain
#         self._domain = list(map(float, x))
#         return self.rescale()
# 
#     def range(self, x=None):
#         if x is None:
#             return self._range
#         self._range = x
#         return self.rescale()
# 
#     def rangeRound(self, x):
#         pass
# 
#     def clamp(self, x=None):
#         if x is None:
#             return self._clamp
#         self._clamp = x
#         return self.rescale()
# 
#     def interpolate(self, x=None):
#         if x is None:
#             return self._interpolate
#         self._interpolate = x
#         return self.rescale()
# 
#     def ticks(self, m=None):
#         return d3_scale_linearTicks(self._domain, m)
# 
#     def tickFormat(self, m=None, fmt=None):
#         return d3_scale_linearTickFormat(self._domain, m, fmt)
# 
#     def nice(self, m=None):
#         d3_scale_linearNice(self._domain, m)
#         return self.rescale()
# 
#     def copy(self):
#         return LinearScale(
#             self._domain, self._range, self._interpolate, self._clamp
#         )
# 
#     def __call__(self, x):
#         return self._output(x)


import unittest
from labella.scale import LinearScale
        self.assertAlmostEqual(x.invert(1), 0)
        self.assertAlmostEqual(x.invert(1.5), 0.5)
        self.assertAlmostEqual(x.invert(2), 1)
        self.assertAlmostEqual(x.invert(2.5), 1.5)

    def test_ticks_1(self):
        # generates tixcks of varying degree
        x = LinearScale()
        exp = [0, 1]
        res = [float(y) for y in list(map(x.tickFormat(1), x.ticks(1)))]
        for i, j in zip(res, exp):
            self.assertEqual(i, j)

        exp = [0, 0.5, 1]
        res = [float(y) for y in list(map(x.tickFormat(2), x.ticks(2)))]
        for i, j in zip(res, exp):
            self.assertEqual(i, j)

        exp = [0, 0.2, 0.4, 0.6, 0.8, 1]
        res = [float(y) for y in list(map(x.tickFormat(5), x.ticks(5)))]
        for i, j in zip(res, exp):
            self.assertEqual(i, j)

        exp = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]
        res = [float(y) for y in list(map(x.tickFormat(10), x.ticks(10)))]
        for i, j in zip(res, exp):
            self.assertEqual(i, j)

    def test_ticks_2(self):
        # generates tixcks of varying degree

# Path: labella/scale.py
# class LinearScale(object):
#     def __init__(
#         self, domain=None, _range=None, interpolate=None, clamp=False
#     ):
#         self._domain = [0, 1] if domain is None else domain
#         self._range = [0, 1] if _range is None else _range
#         self._interpolate = (
#             d3_interpolate if interpolate is None else interpolate
#         )
#         self._clamp = clamp
# 
#         self._output = None
#         self._input = None
#         self.rescale()
# 
#     def rescale(self):
#         linear = d3_scale_bilinear
#         if self._clamp:
#             uninterpolate = d3_uninterpolateClamp
#         else:
#             uninterpolate = d3_uninterpolateNumber
#         self._output = linear(
#             self._domain, self._range, uninterpolate, self._interpolate
#         )
#         self._input = linear(
#             self._range, self._domain, uninterpolate, d3_interpolate
#         )
#         return self
# 
#     def scale(self, x):
#         return self._output(x)
# 
#     def invert(self, y):
#         return self._input(y)
# 
#     def domain(self, x=None):
#         if x is None:
#             return self._domain
#         self._domain = list(map(float, x))
#         return self.rescale()
# 
#     def range(self, x=None):
#         if x is None:
#             return self._range
#         self._range = x
#         return self.rescale()
# 
#     def rangeRound(self, x):
#         pass
# 
#     def clamp(self, x=None):
#         if x is None:
#             return self._clamp
#         self._clamp = x
#         return self.rescale()
# 
#     def interpolate(self, x=None):
#         if x is None:
#             return self._interpolate
#         self._interpolate = x
#         return self.rescale()
# 
#     def ticks(self, m=None):
#         return d3_scale_linearTicks(self._domain, m)
# 
#     def tickFormat(self, m=None, fmt=None):
#         return d3_scale_linearTickFormat(self._domain, m, fmt)
# 
#     def nice(self, m=None):
#         d3_scale_linearNice(self._domain, m)
#         return self.rescale()
# 
#     def copy(self):
#         return LinearScale(
#             self._domain, self._range, self._interpolate, self._clamp
#         )
# 
#     def __call__(self, x):
#         return self._output(x)


# Path: tests/test_scale_linear.py
import unittest
from labella.scale import LinearScale

        self.assertAlmostEqual(x.invert(1), 0)
        self.assertAlmostEqual(x.invert(1.5), 0.5)
        self.assertAlmostEqual(x.invert(2), 1)
        self.assertAlmostEqual(x.invert(2.5), 1.5)

    def test_ticks_1(self):
        # generates tixcks of varying degree
        x = LinearScale()
        exp = [0, 1]
        res = [float(y) for y in list(map(x.tickFormat(1), x.ticks(1)))]
        for i, j in zip(res, exp):
            self.assertEqual(i, j)

        exp = [0, 0.5, 1]
        res = [float(y) for y in list(map(x.tickFormat(2), x.ticks(2)))]
        for i, j in zip(res, exp):
            self.assertEqual(i, j)

        exp = [0, 0.2, 0.4, 0.6, 0.8, 1]
        res = [float(y) for y in list(map(x.tickFormat(5), x.ticks(5)))]
        for i, j in zip(res, exp):
            self.assertEqual(i, j)

        exp = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]
        res = [float(y) for y in list(map(x.tickFormat(10), x.ticks(10)))]
        for i, j in zip(res, exp):
            self.assertEqual(i, j)

    def test_ticks_2(self):
        # generates tixcks of varying degree

        x = LinearScale([1, 0])