1. 26 Aug, 2016 5 commits
  2. 24 Aug, 2016 6 commits
    • Release Manager's avatar
      Trac #21322: coerce_binop has dangerous behaviour wrt additional arguments · 2a4fd71c
      Release Manager authored
      `@coerce_binop` is an important decorator used on binary operators to
      automagically apply the coercion framework on its arguments. It's widely
      used on e.g. `gcd` operations (`_add_`, `_sub_` etc. have coercion
      handled with another mechanism).
      The current `@coerce_binop` has the following dangerous behaviour,
      where, if the decorated method is given an extra unnamed argument, the
      `self`-argument is swallowed:
          sage: P.<x> = GF(5)[]
          sage: f = x^2
          sage: g = x
          sage: f.gcd(g)
          sage: f.gcd(g, 1)
      The reason is that `@coerce_binop` included a hack to allow calls such
      `Polynomial.gcd(f,g)` where `f` and `g` are polynomials and the `gcd`
      method is
      decorated with `@coerce_binop`. The reason that this required a hack at
      all is that `@coerce_binop` was implemented as a class: it seems that
      creating decorators as classes implies a very unfortunate behaviour:
      class MyDec:
         def __init__(self, f):
             self.f = f
         def __call__(self, x):
             print "decorated: ", self , x
      mydec = MyDec
      class A:
          def __init__(self, a):
              self.a = a
          def met(self, x):
              print "x:", x
      myA = A(1)
      the above prints something like
          decorated:  <__main__.MyDec instance at 0x7f63c5ab6c20> 5
      and then crashes with
          AttributeError: MyDec instance has no attribute 'a'
      This is because the `self` in `__call__` of `MyDec` becomes the `MyDec`
      -- the `A` instance is never passed to the decorating class instance!
      The solution here is to rewrite `coerce_binop` as a function. At the
      same time, we can use `@sage_wraps` which ensures proper documentation
      (e.g. source file and line which was not retained in the previous
      URL: https://trac.sagemath.org/21322
      Reported by: jsrn
      Ticket author(s): Johan Rosenkilde, Xavier Caruso
      Reviewer(s): Miguel Marco
    • Release Manager's avatar
      Trac #21310: py3: remove itervalues in combinat folder · e009780a
      Release Manager authored
      as a step towards py3, use six to get rid of itervalues
      in this ticket, only for the combinat folder
      URL: https://trac.sagemath.org/21310
      Reported by: chapoton
      Ticket author(s): Frédéric Chapoton
      Reviewer(s): Jori Mäntysalo
    • Release Manager's avatar
      Trac #21308: implement the magnitude function of a graph · 7eadd9b8
      Release Manager authored
      the magnitude function is some kind of generalized  Euler characteristic
      defined for metric spaces
      in particular, graphs can be seen as metric spaces with edges of length
      Let us implement the magnitude function for graphs.
      URL: https://trac.sagemath.org/21308
      Reported by: chapoton
      Ticket author(s): Frédéric Chapoton
      Reviewer(s): Jori Mäntysalo
    • Release Manager's avatar
      Trac #21298: Implement abelian_variety() to elliptic curves · 3438a8a4
      Release Manager authored
      If `E` is an elliptic curve then `E.abelian_variety()` will return `E`
      as a modular abelian variety.
      URL: https://trac.sagemath.org/21298
      Reported by: klui
      Ticket author(s): Kevin Lui
      Reviewer(s): Aly Deines
    • Xavier Caruso's avatar
      Small change in a doctest · 7344f3a7
      Xavier Caruso authored
    • Xavier Caruso's avatar
      Small fixes. All doctests pass (hopefully) · cfb53263
      Xavier Caruso authored
  3. 23 Aug, 2016 8 commits
  4. 22 Aug, 2016 11 commits
  5. 21 Aug, 2016 10 commits
    • kevin lui's avatar
      added automorphisms to rational_field · 1424bbc5
      kevin lui authored
    • Frédéric Chapoton's avatar
      detail · b7b4f52a
      Frédéric Chapoton authored
    • Release Manager's avatar
      Trac #21293: Posets: add algorithm-keyword to canonical_relabel() · ce0a49f0
      Release Manager authored
      Add the `algorithm`-keyword to canonical labeling of posets and forward
      the argument to the same function in graphs.
      URL: https://trac.sagemath.org/21293
      Reported by: jmantysalo
      Ticket author(s): Jori Mäntysalo
      Reviewer(s): Martin Rubey
    • Release Manager's avatar
      Trac #21285: change ring does not work for affine morphisms · e4a5ac4f
      Release Manager authored
      the following does not work
       K.<a> = QuadraticField(-1)
       A.<x,y> = AffineSpace(K, 2)
       H = End(A)
       phi = H([x/y, y])
       emb = K.embeddings(QQbar)[0]
      since the coordiante ring is a fraction field
      URL: https://trac.sagemath.org/21285
      Reported by: bhutz
      Ticket author(s): Ben Hutz
      Reviewer(s): Grayson Jorgenson
    • Release Manager's avatar
      Trac #21193: remove \atop and \choose · 8625f3b0
      Release Manager authored
      Those old-style latex expressions are giving pdf warnings.
      URL: https://trac.sagemath.org/21193
      Reported by: chapoton
      Ticket author(s): Frédéric Chapoton
      Reviewer(s): André Apitzsch
    • Release Manager's avatar
      Trac #20857: Implement an() for modular forms · e7f2c477
      Release Manager authored
      If f is a newform, then f.an(n) will return the nth coefficient in its
      URL: https://trac.sagemath.org/20857
      Reported by: klui
      Ticket author(s): Kevin Lui
      Reviewer(s): Peter Bruin, William Stein
    • Release Manager's avatar
      Trac #21276: Poset: add jump_number() · a13bb37d
      Release Manager authored
      This patch will add a dumb implementation to compute the jump number of
      a poset.
      URL: https://trac.sagemath.org/21276
      Reported by: jmantysalo
      Ticket author(s): Jori Mäntysalo
      Reviewer(s): Frédéric Chapoton
    • Release Manager's avatar
      Trac #21238: Random failure in tutorial_free_modules.py · ce3206bd
      Release Manager authored
      Comparison between integers and strings is by memory position, hence
      random order here:
      sage -t --long src/sage/modules/tutorial_free_modules.py
      File "src/sage/modules/tutorial_free_modules.py", line 45, in
      Failed example:
          F = CombinatorialFreeModule(ZZ, ['spam', 'eggs', 42]);
          3*B[42] + 2*B['eggs'] + 2*B['spam']
          2*B['eggs'] + 2*B['spam'] + 3*B[42]
      1 item had failures:
         1 of  43 in sage.modules.tutorial_free_modules
          [42 tests, 1 failure, 0.43 s]
      URL: https://trac.sagemath.org/21238
      Reported by: vbraun
      Ticket author(s): Frédéric Chapoton
      Reviewer(s): Volker Braun, Travis Scrimshaw
    • Release Manager's avatar
      Trac #21191: Improve support for warnings in doctester · 514bd1ae
      Release Manager authored
      When a warning happens in the doctester, the source filename is always
      replaced by `doctest`. This should be fixed.
      Second, we display a complete traceback instead of just the warning
      message for warnings raised while doctesting.
      URL: https://trac.sagemath.org/21191
      Reported by: jdemeyer
      Ticket author(s): Jeroen Demeyer
      Reviewer(s): Frédéric Chapoton
    • Release Manager's avatar
      Trac #20924: Error in plot - force use of aspect ratio · 77db56e8
      Release Manager authored
      It seems as though when using plot() we are forced to have an aspect
      ratio of automatic whether we want that or not. Example:
      If we define a class
      class something:
          def plot(self):
              G = Graphics()
              return G
      when we do something.plot() the aspect ratio is correctly set to 1. But
      when we do plot(something) the aspect ratio gets converted to automatic.
      This is due to the native way that plot is handled:
      file: src/sage/plot/plot.py
      @Options(alpha=1, thickness=1, fill=False, fillcolor='automatic',
      fillalpha=0.5, rgbcolor=(0,0,1), plot_points=200,
      adaptive_tolerance=0.01, adaptive_recursion=5, detect_poles = False,
      exclude = None, legend_label=None, __original_opts=True,
      def plot(funcs, *args, **kwds):
            G_kwds = Graphics._extract_kwds_for_show(kwds, ignore=['xmin',
            original_opts = kwds.pop('__original_opts', {})
            do_show = kwds.pop('show',False)
            from sage.structure.element import is_Vector
            if kwds.get('parametric',False) and is_Vector(funcs):
                funcs = tuple(funcs)
            if hasattr(funcs, 'plot'):
                G = funcs.plot(*args, **original_opts)
            # if we are using the generic plotting method
                # Other things - deleted for clarity
            if do_show:
            return G
      Notice how the last option in @Options is aspect_ratio='automatic'. The
      reason that this is the only one with an issue is the comination of
      Graphics._extract_kwds_for_show and G._set_extra_kwds.
      When using Graphics._extract_kwds_for_show we are doing the following:
      file: src/sage/plot/graphics.py
          SHOW_OPTIONS = dict(# axes options
                              axes=None, axes_labels=None,
                              axes_pad=None, base=None, scale=None,
                              xmin=None, xmax=None, ymin=None, ymax=None,
                              # Figure options
                              aspect_ratio=None, dpi=DEFAULT_DPI,
                              figsize=None, fontsize=None, frame=False,
                              title=None, title_pos=None, transparent=False,
                              # Grid options
                              gridlines=None, gridlinesstyle=None,
                              hgridlinesstyle=None, vgridlinesstyle=None,
                              # Legend options
                              legend_options={}, show_legend=None,
                              # Ticks options
                              ticks=None, tick_formatter=None,
                              # Text options
          def _extract_kwds_for_show(cls, kwds, ignore=[]):
              result = {}
              for option in cls.SHOW_OPTIONS:
                  if option not in ignore:
                          result[option] = kwds.pop(option)
                      except KeyError:
              return result
      As you can see, we always grab these additional kwds, in particular we
      grab the 'aspect_ratio' kwd. This means that when G._set_extra_kwds gets
      called, the aspect ratio is changing AFTER we have already set it in our
      something.plot() method.
      It seems as though this is not working as expected and/or there is some
      non-intuitive way to get around this issue.
       - We should only be doing _set_extra_kwds if we are NOT using the plot
      method of an object
       - Or we should have some way to override this property so that if we
      are setting an aspect ratio, then it does not get forcibly overwritten
      as is happening now.
      I'm thinking of doing the second one, where I do something of the
      following nature:
            if hasattr(funcs, 'plot'):
                G = funcs.plot(*args, **original_opts)
                for ext in G._extra_kwds
                    if ext in G_kwds:
                         delete G_kwds[ext]
      Like this, if we are ever setting something beforehand, we are not
      unintentionally removing it as we are now.
      Thoughts would be beneficial on this ticket as plot is a fairly common
      tool that is used in multiple places and so I don't want to alter
      something that might break other things especially if there does
      actually exist something that would get around this issue that I don't
      know about and/or if someone has a different idea of how to approach it.
      Thank you.
      URL: https://trac.sagemath.org/20924
      Reported by: aram.dermenjian
      Ticket author(s): Aram Dermenjian
      Reviewer(s): Paul Masson, Aaron Lauve, Travis Scrimshaw