Ticket #3813: 3813-diff.patch

File 3813-diff.patch, 5.4 KB (added by ncalexan, 5 years ago)
  • sage/plot/plot.py

    a b  
    34193419        adaptive_recursion -- (default: 5) how many levels of recursion to go  
    34203420                              before giving up when doing adaptive refinement. 
    34213421                              Setting this to 0 disables adaptive refinement. 
    3422         adaptive_tolerance -- how large a difference should be before the 
    3423                               adaptive refinement code considers it significant. 
    3424                               This depends on the interval you use by default. 
     3422        adaptive_tolerance -- (default: 0.01) how large a difference should be 
     3423                              before the adaptive refinement code considers it 
     3424                              significant.  Use a smaller value for smoother 
     3425                              plots and a larger value for coarser plots.  In 
     3426                              general, adjust adaptive_recursion before 
     3427                              adaptive_tolerance, and consult the code of 
     3428                              adaptive_refinement for the details. 
     3429 
    34253430        xmin -- starting x value 
    34263431        xmax -- ending x value 
    34273432        color -- an rgb-tuple (r,g,b) with each of r,g,b between 0 and 1, or 
     
    35593564    def _reset(self): 
    35603565        o = self.options 
    35613566        o['plot_points'] = 200 
     3567        o['adaptive_tolerance'] = 0.01 
    35623568        o['adaptive_recursion'] = 5 
    35633569        o['rgbcolor'] = (0,0,1)    
    35643570 
     
    36953701            warnings.warn("plot_division is deprecated. See adaptive_recursion in the documentation for plot()", DeprecationWarning, stacklevel=3) 
    36963702        # adaptive refinement 
    36973703        i, j = 0, 0 
    3698         if 'adaptive_tolerance' in options: 
    3699             adaptive_tolerance = float(options['adaptive_tolerance']) 
    3700             del options['adaptive_tolerance'] 
    3701         else: 
    3702             adaptive_tolerance = delta * 0.01 
     3704        adaptive_tolerance = delta * float(options['adaptive_tolerance']) 
     3705        del options['adaptive_tolerance'] 
    37033706        adaptive_recursion = int(options['adaptive_recursion']) 
    37043707        del options['adaptive_recursion'] 
    37053708         
    37063709        while i < len(data) - 1: 
    37073710            for p in adaptive_refinement(f, data[i], data[i+1],  
    3708                             adaptive_tolerance, adaptive_recursion): 
     3711                                         adaptive_tolerance=adaptive_tolerance, 
     3712                                         adaptive_recursion=adaptive_recursion): 
    37093713                data.insert(i+1, p) 
    37103714                i += 1 
    37113715            i += 1 
     
    44984502        adaptive_recursion -- (default: 10) how many levels of recursion to go  
    44994503                              before giving up when doing adaptive refinement. 
    45004504                              Setting this to 0 disables adaptive refinement. 
    4501         adaptive_tolerance -- (default 0.01) how large a difference should be  
     4505        adaptive_tolerance -- (default: 0.01) how large a difference should be 
    45024506                              before the adaptive refinement code considers  
    4503                               it significant. 
     4507                              it significant.  See the documentation for 
     4508                              plot() for more information. 
    45044509     
    45054510    OUTPUT: 
    45064511        list -- a list of points to insert between p1 and p2 to get 
     
    45084513 
    45094514    TESTS: 
    45104515        sage: from sage.plot.plot import adaptive_refinement 
    4511         sage: adaptive_refinement(sin, (0,0), (pi,0), 0.01, level=10) 
     4516        sage: adaptive_refinement(sin, (0,0), (pi,0), adaptive_tolerance=0.01, level=10) 
    45124517        [] 
    4513         sage: adaptive_refinement(sin, (0,0), (pi,0), 0.01) 
    4514         [(0.125000000000000*pi, 0.38268343236508978), (0.187500000000000*pi, 0.55557023301960218), (0.250000000000000*pi, 0.70710678118654757), (0.312500000000000*pi, 0.83146961230254524), (0.375000000000000*pi, 0.92387953251128674), (0.437500000000000*pi, 0.98078528040323043), (0.500000000000000*pi, 1.0), (0.562500000000000*pi, 0.98078528040323043), (0.625000000000000*pi, 0.92387953251128674), (0.687500000000000*pi, 0.83146961230254546), (0.750000000000000*pi, 0.70710678118654757), (0.812500000000000*pi, 0.55557023301960218), (0.875000000000000*pi, 0.38268343236508989)] 
     4518        sage: adaptive_refinement(sin, (0,0), (pi,0), adaptive_tolerance=0.01) 
     4519        [(0.125000000000000*pi, 0.38268343236508978), (0.187500000000000*pi, 0.55557023301960218), (0.250000000000000*pi, 0.707106781186547...), (0.312500000000000*pi, 0.83146961230254524), (0.375000000000000*pi, 0.92387953251128674), (0.437500000000000*pi, 0.98078528040323043), (0.500000000000000*pi, 1.0), (0.562500000000000*pi, 0.98078528040323043), (0.625000000000000*pi, 0.92387953251128674), (0.687500000000000*pi, 0.83146961230254546), (0.750000000000000*pi, 0.70710678118654757), (0.812500000000000*pi, 0.55557023301960218), (0.875000000000000*pi, 0.38268343236508989)] 
     4520 
     4521        This shows that lowering adaptive_tolerance and raising 
     4522        adaptive_recursion both increase the number of subdivision points: 
     4523 
     4524        sage: x = var('x') 
     4525        sage: f = sin(1/x) 
     4526        sage: n1 = len(adaptive_refinement(f, (0,0), (pi,0), adaptive_tolerance=0.01)); n1 
     4527        79 
     4528        sage: n2 = len(adaptive_refinement(f, (0,0), (pi,0), adaptive_recursion=5, adaptive_tolerance=0.01)); n2 
     4529        15 
     4530        sage: n1 > n2 
     4531        True 
     4532 
     4533        sage: n3 = len(adaptive_refinement(f, (0,0), (pi,0), adaptive_tolerance=0.005)); n3 
     4534        88 
     4535        sage: n1 < n3 
     4536        True 
    45154537    """ 
    45164538    if level >= adaptive_recursion: 
    45174539        return []