Ticket #9812: trac_9812_sorting_bug_in_fan_subdivision.patch

File trac_9812_sorting_bug_in_fan_subdivision.patch, 1.9 KB (added by novoselt, 9 years ago)
  • sage/geometry/fan.py

    # HG changeset patch
    # User Andrey Novoseltsev <novoselt@gmail.com>
    # Date 1282861565 21600
    # Node ID fd3572c42f5d0744c96df4a5ea51804dac98f0c2
    # Parent  c9b5af6af88ac4b38198df54002373e9d54f5316
    Trac 9812: Fix sorting bug in subdivision algorithm of rational polyhedral cones.
    
    diff -r c9b5af6af88a -r fd3572c42f5d sage/geometry/fan.py
    a b  
    12421242            sage: for cone in new_fan: print cone.ambient_ray_indices()
    12431243            (0, 2)
    12441244            (1, 2)
     1245           
     1246        We make sure that this function constructs cones with ordered ambient
     1247        ray indices (see Trac 9812)::
     1248       
     1249            sage: C = Cone([(1,0,0), (0,1,0), (1,0,1), (0,1,1)])
     1250            sage: F = Fan([C]).make_simplicial()
     1251            sage: [cone.ambient_ray_indices() for cone in F]
     1252            [(0, 1, 3), (0, 1, 2)]       
    12451253        """
    12461254        dim = self.lattice_dim()
    12471255        for cone in self:
     
    13001308        new_fan_rays = list(self.rays())
    13011309        new_fan_rays.extend(ray for ray in new_rays
    13021310                                if ray not in self.ray_set())
    1303         cones = tuple(tuple(new_fan_rays.index(cone_polytope.vertex(v))
    1304                             for v in range(cone_polytope.nvertices() - 1))
     1311        cones = tuple(tuple(sorted(new_fan_rays.index(cone_polytope.vertex(v))
     1312                            for v in range(cone_polytope.nvertices() - 1)))
    13051313                      for cone_polytope in cone_polytopes)
    13061314        fan = Fan(cones, new_fan_rays, check=False, normalize=False)
    1307         # Since we already have all lattice polytopes, let's keep them
    1308         for cone, polytope in zip(fan.generating_cones(), cone_polytopes):
    1309             cone._lattice_polytope = polytope
    13101315        return fan
    13111316
    13121317    def cone_containing(self, *points):