def test_dihedral_special_cases(self):
    a = Position(random(), random(), random())
    self.assertEqual(gemmi.calculate_dihedral(a, a, a, a), 0.0)
    p000 = Position(0, 0, 0)
    p100 = Position(1, 0, 0)
    p010 = Position(0, 1, 0)

    def xy_dihedral(last_point):
        return gemmi.calculate_dihedral(p100, p000, p010, last_point)
    self.assertEqual(xy_dihedral(Position(1, 1, 0)), 0.0)
    self.assertEqual(xy_dihedral(Position((- 1), 1, 0)), pi)
    p01_ = Position(0, 1, (- 1))
    self.assertEqual(xy_dihedral(p01_), (pi / 2))
    p01_.z = 1
    self.assertEqual(xy_dihedral(p01_), ((- pi) / 2))
def test_dihedral_special_cases(self):
    a = Position(random(), random(), random())
    self.assertEqual(gemmi.calculate_dihedral(a, a, a, a), 0.0)
    p000 = Position(0, 0, 0)
    p100 = Position(1, 0, 0)
    p010 = Position(0, 1, 0)

    def xy_dihedral(last_point):
        return gemmi.calculate_dihedral(p100, p000, p010, last_point)
    self.assertEqual(xy_dihedral(Position(1, 1, 0)), 0.0)
    self.assertEqual(xy_dihedral(Position((- 1), 1, 0)), pi)
    p01_ = Position(0, 1, (- 1))
    self.assertEqual(xy_dihedral(p01_), (pi / 2))
    p01_.z = 1
    self.assertEqual(xy_dihedral(p01_), ((- pi) / 2))