def test_nice_2(self): # has no effect on degenerate domains x = LinearScale().domain([0, 0]).nice() self.assertEqual(x.domain(), [0, 0]) x = LinearScale().domain([0.5, 0.5]).nice() self.assertEqual(x.domain(), [0.5, 0.5])
def test_nice_2(self): # has no effect on degenerate domains x = LinearScale().domain([0, 0]).nice() self.assertEqual(x.domain(), [0, 0]) x = LinearScale().domain([0.5, 0.5]).nice() self.assertEqual(x.domain(), [0.5, 0.5])
def test_nice_3(self): # accepts a tick count to control nicing step x = LinearScale().domain([12, 87]).nice(5) self.assertEqual(x.domain(), [0, 100]) x = LinearScale().domain([12, 87]).nice(10) self.assertEqual(x.domain(), [10, 90]) x = LinearScale().domain([12, 87]).nice(100) self.assertEqual(x.domain(), [12, 87])
def test_nice_3(self): # accepts a tick count to control nicing step x = LinearScale().domain([12, 87]).nice(5) self.assertEqual(x.domain(), [0, 100]) x = LinearScale().domain([12, 87]).nice(10) self.assertEqual(x.domain(), [10, 90]) x = LinearScale().domain([12, 87]).nice(100) self.assertEqual(x.domain(), [12, 87])
def test_copy_1(self): # changes to the domain are isolated x = LinearScale() y = x.copy() x.domain([1, 2]) self.assertEqual(y.domain(), [0, 1]) self.assertEqual(x(1), 0) self.assertEqual(y(1), 1) y.domain([2, 3]) self.assertEqual(x(2), 1) self.assertEqual(y(2), 0) self.assertEqual(x.domain(), [1, 2]) self.assertEqual(y.domain(), [2, 3])
def test_copy_1(self): # changes to the domain are isolated x = LinearScale() y = x.copy() x.domain([1, 2]) self.assertEqual(y.domain(), [0, 1]) self.assertEqual(x(1), 0) self.assertEqual(y(1), 1) y.domain([2, 3]) self.assertEqual(x(2), 1) self.assertEqual(y(2), 0) self.assertEqual(x.domain(), [1, 2]) self.assertEqual(y.domain(), [2, 3])
def test_nice_1(self): # nices the domain, extending it to round numbers x = LinearScale().domain([1.1, 10.9]).nice() self.assertEqual(x.domain(), [1, 11]) x = LinearScale().domain([10.9, 1.1]).nice() self.assertEqual(x.domain(), [11, 1]) x = LinearScale().domain([0.7, 11.001]).nice() self.assertEqual(x.domain(), [0, 12]) x = LinearScale().domain([123.1, 6.7]).nice() self.assertEqual(x.domain(), [130, 0]) x = LinearScale().domain([0, 0.49]).nice() self.assertEqual(x.domain(), [0, 0.5]) x = LinearScale().domain([-0.1, 51.1]).nice(8) self.assertEqual(x.domain(), [-10, 60])
def test_nice_1(self): # nices the domain, extending it to round numbers x = LinearScale().domain([1.1, 10.9]).nice() self.assertEqual(x.domain(), [1, 11]) x = LinearScale().domain([10.9, 1.1]).nice() self.assertEqual(x.domain(), [11, 1]) x = LinearScale().domain([0.7, 11.001]).nice() self.assertEqual(x.domain(), [0, 12]) x = LinearScale().domain([123.1, 6.7]).nice() self.assertEqual(x.domain(), [130, 0]) x = LinearScale().domain([0, 0.49]).nice() self.assertEqual(x.domain(), [0, 0.5]) x = LinearScale().domain([-0.1, 51.1]).nice(8) self.assertEqual(x.domain(), [-10, 60])
def test_domain_1(self): # defaults to [0, 1] x = LinearScale() self.assertEqual(x.domain(), [0, 1]) self.assertAlmostEqual(x(0.5), 0.5)
def test_domain_1(self): # defaults to [0, 1] x = LinearScale() self.assertEqual(x.domain(), [0, 1]) self.assertAlmostEqual(x(0.5), 0.5)