Ticket #9972: trac_9972_fix_fan_warning.patch

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

    # HG changeset patch
    # User Andrey Novoseltsev <novoselt@gmail.com>
    # Date 1287856785 21600
    # Node ID e5c283286bc1b9bd9af5e9ddaf8e1bab3ac99837
    # Parent  6ce4f6a17ba3d6b05705a5addf7108053563b9c8
    Trac 9972: Allow turning off warnings about discarding cones during fan construction.
    
    diff -r 6ce4f6a17ba3 -r e5c283286bc1 sage/geometry/fan.py
    a b  
    263263
    264264
    265265def Fan(cones, rays=None, lattice=None, check=True, normalize=True,
    266         is_complete=None):
     266        is_complete=None, discard_warning=True):
    267267    r"""
    268268    Construct a rational polyhedral fan.
    269269
     
    318318      pass ``is_complete=False`` option, although it is less likely to be
    319319      beneficial. Of course, passing a wrong value can compromise the
    320320      integrity of data structures of the fan and lead to wrong results, so
    321       you should be very careful if you decide to use this option.
     321      you should be very careful if you decide to use this option;
     322     
     323    - ``discard_warning`` -- by default, the fan constructor will show a
     324      warning the first time you try to construct a fan from non-generating
     325      cones, in which case some of them will be automatically discarded. If you
     326      are writing a code where it is reasonable to expect extra cones as input,
     327      you may pass ``discard_warning=False`` option to suppress this warning.
    322328
    323329    OUTPUT:
    324330
     
    477483                                % (g_cone.rays(), cone.rays()))
    478484                if is_generating:
    479485                    generating_cones.append(cone)
    480             if len(cones) > len(generating_cones):
     486            if discard_warning and len(cones) > len(generating_cones):
    481487                warnings.warn("you have provided a non-minimal set of "
    482488                    "generating cones, %d of them were discarded!"
    483489                    % (len(cones) - len(generating_cones)),
     
    497503        return RationalPolyhedralFan(cones, rays, lattice, is_complete)
    498504    # If we do need to make all the check, build explicit cone objects first
    499505    return Fan((Cone([rays[n] for n in cone], lattice) for cone in cones),
    500                rays, lattice, is_complete=is_complete)
     506               rays, lattice, is_complete=is_complete,
     507               discard_warning=discard_warning)
    501508
    502509
    503510def FaceFan(polytope, lattice=None):
  • sage/geometry/fan_morphism.py

    diff -r 6ce4f6a17ba3 -r e5c283286bc1 sage/geometry/fan_morphism.py
    a b  
    401401        domain_fan = self._domain_fan
    402402        self._codomain_fan = Fan(cones=(domain_cone.ambient_ray_indices()
    403403                                        for domain_cone in domain_fan),
    404                                  rays=(self(ray) for ray in domain_fan.rays()))
     404                                 rays=(self(ray) for ray in domain_fan.rays()),
     405                                 discard_warning=False)
    405406   
    406407    def _latex_(self):
    407408        r"""