def test_path_to_discriminant_point_abel_ordering(self):
        # the way abel complex paths are constructed ensure that all points
        # along the path to bi lie above all discriminant points below bi and
        # above all discriminant points below bi. this will test that scenario
        #
        # note that this particular test doesn't really work for paths to
        # co-linear points
        f = self.f3
        CPF = ComplexPathFactory(f, -2, kappa=0.5)

        # 1.j lies above all other discriminant points. make sure the points
        # along the path all lie above the other discriminant point
        #
        # ignore the base point in these tests
        path = CPF.path_to_discriminant_point(1.j)
        s = numpy.linspace(0, 1, 32)
        path_points = path(s)
        centered_path_points = path_points - CPF.base_point

        centered_b0 = CPF.discriminant_points_complex[0] - CPF.base_point
        b0_angles = numpy.angle(centered_path_points - centered_b0)
        self.assertTrue(all(b0_angles[1:] >= 0))

        centered_b1 = CPF.discriminant_points_complex[1] - CPF.base_point
        b1_angles = numpy.angle(centered_path_points - centered_b1)
        self.assertTrue(all(b1_angles[1:] >= 0))

        centered_b2 = CPF.discriminant_points_complex[2] - CPF.base_point
        b2_angles = numpy.angle(centered_path_points - centered_b2)
        self.assertTrue(all(b2_angles[1:] >= 0))

        # -1.j lies below all other discriminant points. make sure the points
        # along the path all lie below the other discriminant point
        path = CPF.path_to_discriminant_point(-1.j)
        s = numpy.linspace(0, 1, 32)
        path_points = path(s)
        centered_path_points = path_points - CPF.base_point

        b1_angles = numpy.angle(centered_path_points - centered_b1)
        self.assertTrue(all(b1_angles[1:] <= 0))

        b2_angles = numpy.angle(centered_path_points - centered_b2)
        self.assertTrue(all(b2_angles[1:] <= 0))

        centered_b3 = CPF.discriminant_points_complex[3] - CPF.base_point
        b3_angles = numpy.angle(centered_path_points - centered_b3)
        self.assertTrue(all(b3_angles[1:] <= 0))
    def test_path_to_discriminant_point_abel_ordering(self):
        # the way abel complex paths are constructed ensure that all points
        # along the path to bi lie above all discriminant points below bi and
        # above all discriminant points below bi. this will test that scenario
        #
        # note that this particular test doesn't really work for paths to
        # co-linear points
        f = self.f3
        CPF = ComplexPathFactory(f, -2, kappa=0.5)

        # 1.j lies above all other discriminant points. make sure the points
        # along the path all lie above the other discriminant point
        #
        # ignore the base point in these tests
        path = CPF.path_to_discriminant_point(1.j)
        s = numpy.linspace(0,1,32)
        path_points = path(s)
        centered_path_points = path_points - CPF.base_point

        centered_b0 = CPF.discriminant_points_complex[0] - CPF.base_point
        b0_angles = numpy.angle(centered_path_points - centered_b0)
        self.assertTrue(all(b0_angles[1:] >= 0))

        centered_b1 = CPF.discriminant_points_complex[1] - CPF.base_point
        b1_angles = numpy.angle(centered_path_points - centered_b1)
        self.assertTrue(all(b1_angles[1:] >= 0))

        centered_b2 = CPF.discriminant_points_complex[2] - CPF.base_point
        b2_angles = numpy.angle(centered_path_points - centered_b2)
        self.assertTrue(all(b2_angles[1:] >= 0))

        # -1.j lies below all other discriminant points. make sure the points
        # along the path all lie below the other discriminant point
        path = CPF.path_to_discriminant_point(-1.j)
        s = numpy.linspace(0,1,32)
        path_points = path(s)
        centered_path_points = path_points - CPF.base_point

        b1_angles = numpy.angle(centered_path_points - centered_b1)
        self.assertTrue(all(b1_angles[1:] <= 0))

        b2_angles = numpy.angle(centered_path_points - centered_b2)
        self.assertTrue(all(b2_angles[1:] <= 0))

        centered_b3 = CPF.discriminant_points_complex[3] - CPF.base_point
        b3_angles = numpy.angle(centered_path_points - centered_b3)
        self.assertTrue(all(b3_angles[1:] <= 0))
    def test_path_to_discriminant_point(self):
        #
        f = self.f1
        CPF = ComplexPathFactory(f, -2, kappa=1.0)
        path = CPF.path_to_discriminant_point(0)
        self.assertEqual(path, ComplexLine(-2, -1))

        #
        f = self.f2
        CPF = ComplexPathFactory(f, -1, kappa=1.0)
        path = CPF.path_to_discriminant_point(-1.j)

        z = -sqrt(2.0) / 2.0 - (1 - sqrt(2.0) / 2.0) * 1.j
        w = path(1.0)
        self.assertAlmostEqual(z, w)

        path = CPF.path_to_discriminant_point(1.j)
        z = z.conjugate()
        w = path(1.0)
        self.assertAlmostEqual(z, w)

        # distance between 4th roots of unity = sqrt(2)
        # kappa = 0.5 ==> radius = sqrt(2)/4.0
        f = self.f3
        CPF = ComplexPathFactory(f, -2, kappa=0.5)
        path = CPF.path_to_discriminant_point(-1.j)

        alpha = 1.0 - sqrt(10.0) / 20.0
        z = (2 * alpha - 2) - alpha * 1.0j
        w = path(1.0)
        self.assertAlmostEqual(z, w)

        path = CPF.path_to_discriminant_point(1.j)
        z = z.conjugate()
        w = path(1.0)
        self.assertAlmostEqual(z, w)
    def test_path_to_discriminant_point(self):
        #
        f = self.f1
        CPF = ComplexPathFactory(f, -2, kappa=1.0)
        path = CPF.path_to_discriminant_point(0)
        self.assertEqual(path, ComplexLine(-2,-1))

        #
        f = self.f2
        CPF = ComplexPathFactory(f, -1, kappa=1.0)
        path = CPF.path_to_discriminant_point(-1.j)

        z = -sqrt(2.0)/2.0 - (1-sqrt(2.0)/2.0)*1.j
        w = path(1.0)
        self.assertAlmostEqual(z,w)

        path = CPF.path_to_discriminant_point(1.j)
        z = z.conjugate()
        w = path(1.0)
        self.assertAlmostEqual(z,w)

        # distance between 4th roots of unity = sqrt(2)
        # kappa = 0.5 ==> radius = sqrt(2)/4.0
        f = self.f3
        CPF = ComplexPathFactory(f, -2, kappa=0.5)
        path = CPF.path_to_discriminant_point(-1.j)

        alpha = 1.0-sqrt(10.0)/20.0
        z = (2*alpha-2) - alpha*1.0j
        w = path(1.0)
        self.assertAlmostEqual(z,w)

        path = CPF.path_to_discriminant_point(1.j)
        z = z.conjugate()
        w = path(1.0)
        self.assertAlmostEqual(z,w)