def test_ticks_3(self): # formats ticks with the appropriate precision x = LinearScale([0.123456789, 1.23456789]) res = list(map(x.tickFormat(1), x.ticks(1)))[0] self.assertEqual(res, "1") res = list(map(x.tickFormat(2), x.ticks(2)))[0] self.assertEqual(res, "0.5") res = list(map(x.tickFormat(4), x.ticks(4)))[0] self.assertEqual(res, "0.2") res = list(map(x.tickFormat(8), x.ticks(8)))[0] self.assertEqual(res, "0.2") res = list(map(x.tickFormat(16), x.ticks(16)))[0] self.assertEqual(res, "0.2") res = list(map(x.tickFormat(32), x.ticks(32)))[0] self.assertEqual(res, "0.15") res = list(map(x.tickFormat(64), x.ticks(64)))[0] self.assertEqual(res, "0.14") res = list(map(x.tickFormat(128), x.ticks(128)))[0] self.assertEqual(res, "0.13") res = list(map(x.tickFormat(256), x.ticks(256)))[0] self.assertEqual(res, "0.125")
def test_ticks_3(self): # formats ticks with the appropriate precision x = LinearScale([0.123456789, 1.23456789]) res = list(map(x.tickFormat(1), x.ticks(1)))[0] self.assertEqual(res, "1") res = list(map(x.tickFormat(2), x.ticks(2)))[0] self.assertEqual(res, "0.5") res = list(map(x.tickFormat(4), x.ticks(4)))[0] self.assertEqual(res, "0.2") res = list(map(x.tickFormat(8), x.ticks(8)))[0] self.assertEqual(res, "0.2") res = list(map(x.tickFormat(16), x.ticks(16)))[0] self.assertEqual(res, "0.2") res = list(map(x.tickFormat(32), x.ticks(32)))[0] self.assertEqual(res, "0.15") res = list(map(x.tickFormat(64), x.ticks(64)))[0] self.assertEqual(res, "0.14") res = list(map(x.tickFormat(128), x.ticks(128)))[0] self.assertEqual(res, "0.13") res = list(map(x.tickFormat(256), x.ticks(256)))[0] self.assertEqual(res, "0.125")
def test_ticks_2(self): # generates tixcks of varying degree x = LinearScale([1, 0]) 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]) 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)