Graph drawing in javascript using d3.js
trac #14953 cleanup, pep8 and details
Git directory layout
trac #7191 dirichlet characters over CC

Changes to dirichlet characters to support CC as a base field. In addition
to changing the discrete log table lookup, this makes changes to
gauss_sum(), gauss_sum_numerical(), is_even(), and is_odd(). It is
possible that further changes have to be made, and maybe some more
doctests need to be added.
trac #7191 minor corrections
Merge branch 'develop' into ticket/7191-DirichletGroup_CC

Conflicts:
	src/sage/modular/dirichlet.py
Trac 7191: reviewer patch
trac #14953: Merged with 6.3.beta0
Trac #14680: fix optional dot2tex doctests
trac #16367: IncidenceStructure.automorphism_group : correct labels
Merge branch 'develop' into ticket/7191-DirichletGroup_CC

Conflicts:
	src/sage/modular/dirichlet.py
trac #16358: Merged with 6.3.beta2
trac #16367: Merged with updated #16358
Trac #16367: IncidenceStructure.automorphism_group : correct labels

PermutationGroup can handle permutations on any set, and not only 1..n.
Given that the designs are defined on `range(v)`, let us avoid some
mistakes !

Before
{{{
sage: designs.BalancedIncompleteBlockDesign(7,3).automorphism_group()
Permutation Group with generators [(3,5)(6,7), (3,6)(5,7), (2,3)(4,5),
(1,2)(5,7)]
sage: designs.BalancedIncompleteBlockDesign(7,3).points()
[0, 1, 2, 3, 4, 5, 6]
}}}

After

{{{
sage: designs.BalancedIncompleteBlockDesign(7,3).automorphism_group()
Permutation Group with generators [(2,4)(5,6), (2,5)(4,6), (1,2)(3,4),
(0,1)(4,6)]
sage: designs.BalancedIncompleteBlockDesign(7,3).points()
[0, 1, 2, 3, 4, 5, 6]
}}}

URL: http://trac.sagemath.org/16367
Reported by: ncohen
Ticket author(s): Nathann Cohen
Reviewer(s): Vincent Delecroix
Trac #14953: Graph drawing in javascript using d3.js

As the title says.

This drawing method will be as good as the examples that are used to
tune its parameters `:-)`

Nathann

URL: http://trac.sagemath.org/14953
Reported by: ncohen
Ticket author(s): Nathann Cohen, Brice Onfroy
Reviewer(s): Dima Pasechnik
Trac #14680: fix broken optional dot2tex doctests

Some optional dot2tex doctests are broken. Running `sage -t
--optional=dot2tex,graphviz,sage` on the files containing the string
{{{dot2tex}}}, I get the following errors (with sage-6.3.beta1):

{{{
----------------------------------------------------------------------
sage -t sage/combinat/posets/posets.py  # 1 doctest failed
sage -t sage/graphs/graph_latex.py  # 1 doctest failed
----------------------------------------------------------------------
}}}

More precisely:

{{{
sage -t sage/combinat/posets/posets.py
**********************************************************************
File "sage/combinat/posets/posets.py", line 1118, in
sage.combinat.posets.posets.FinitePoset._latex_
Failed example:
    print P._latex_() #optional - dot2tex graphviz
Expected:
    \begin{tikzpicture}[>=latex,line join=bevel,]
    %%
    \node (node_1) at (6bp,57bp) [draw,draw=none] {$2$};
      \node (node_0) at (6bp,7bp) [draw,draw=none] {$1$};
      \draw [black,<-] (node_1) ..controls (6bp,31.269bp) and
(6bp,20.287bp)  .. (node_0);
    %
    \end{tikzpicture}
Got:
    <BLANKLINE>
    \begin{tikzpicture}[>=latex,line join=bevel,]
    %%
    \node (node_1) at (6.000000bp,57.000000bp) [draw,draw=none] {$2$};
      \node (node_0) at (6.000000bp,7.000000bp) [draw,draw=none] {$1$};
      \draw [black,<-] (node_1) ..controls (6.000000bp,31.269000bp) and
(6.000000bp,20.287000bp)  .. (node_0);
    %
    \end{tikzpicture}
    <BLANKLINE>
**********************************************************************
}}}

and

{{{
sage -t sage/graphs/graph_latex.py
**********************************************************************
File "sage/graphs/graph_latex.py", line 1346, in
sage.graphs.graph_latex.GraphLatex.dot2tex_picture
Failed example:
    print G.latex_options().dot2tex_picture() # optional - dot2tex
graphviz
Expected:
    \begin{tikzpicture}[>=latex,line join=bevel,]
    %%
    \node (3333) at (...bp,...bp) [draw,draw=none] {$3333$};
      \node (88) at (...bp,...bp) [draw,draw=none] {$88$};
      \draw [black,->] (3333) ..controls (...bp,...bp) and (...bp,...bp)
.. (88);
      \definecolor{strokecol}{rgb}{0.0,0.0,0.0};
      \pgfsetstrokecolor{strokecol}
      \draw (...bp,...bp) node {$\text{\texttt{my{\char`\_}label}}$};
    %
    \end{tikzpicture}
Got:
    <BLANKLINE>
    \begin{tikzpicture}[>=latex,line join=bevel,]
    %%
    \node (node_1) at (13.000000bp,79.000000bp) [draw,draw=none]
{$3333$};
      \node (node_0) at (13.000000bp,7.000000bp) [draw,draw=none]
{$88$};
      \draw [black,->] (node_1) ..controls (13.000000bp,61.492000bp) and
(13.000000bp,39.255000bp)  .. (node_0);
      \definecolor{strokecol}{rgb}{0.0,0.0,0.0};
      \pgfsetstrokecolor{strokecol}
      \draw (40.000000bp,43.000000bp) node
{$\text{\texttt{my{\char`\_}label}}$};
    %
    \end{tikzpicture}
    <BLANKLINE>
**********************************************************************
}}}

For the record, the list of files containing the string "dot2tex" (so
probably containging dot2tex optional doctests) is :

{{{
sage/categories/crystals.py
sage/combinat/crystals/crystals.py
sage/combinat/perfect_matching.py
sage/combinat/posets/linear_extensions.py
sage/combinat/posets/posets.py
sage/combinat/rigged_configurations/kleber_tree.py
sage/graphs/digraph.py
sage/graphs/dot2tex_utils.py
sage/graphs/generic_graph.py
sage/graphs/graph.py
sage/graphs/graph_latex.py
}}}

It is not the first time that dot2tex doctests are broken:

 - http://trac.sagemath.org/sage_trac/ticket/14408#comment:15
 - http://trac.sagemath.org/sage_trac/ticket/14594#comment:30
 - http://trac.sagemath.org/sage_trac/ticket/13624#comment:43

URL: http://trac.sagemath.org/14680
Reported by: slabbe
Ticket author(s): Sébastien Labbé
Reviewer(s): André Apitzsch
Trac #7191: Make Dirichlet characters work when base ring is CC

See the following example:

{{{
sage: G = DirichletGroup(500, base_ring=CC)
sage: G[0].is_primitive()
False
sage: G[1].is_primitive()
------------------------------------------------------------------------
---
KeyError                                  Traceback (most recent call
last)

/home/bober/.sage/temp/bober/24617/_home_bober__sage_init_sage_0.py in
<module>()

/home/bober/sage/local/lib/python2.6/site-
packages/sage/misc/cachefunc.pyc in __call__(self, *args, **kwds)
    240             return cache[key]
    241         else:
--> 242             cache[key] = self.f(self._instance, *args, **kwds)
    243             return cache[key]
    244

/home/bober/sage/local/lib/python2.6/site-
packages/sage/modular/dirichlet.pyc in is_primitive(self)
   1161             True
   1162         """
-> 1163         return (self.conductor() == self.modulus())
   1164
   1165     @cached_method

/home/bober/sage/local/lib/python2.6/site-
packages/sage/misc/cachefunc.pyc in __call__(self, *args, **kwds)
    240             return cache[key]
    241         else:
--> 242             cache[key] = self.f(self._instance, *args, **kwds)
    243             return cache[key]
    244

/home/bober/sage/local/lib/python2.6/site-
packages/sage/modular/dirichlet.pyc in conductor(self)
    624         F = arith.factor(self.modulus())
    625         if len(F) > 1:
--> 626             return misc.mul([d.conductor() for d in
self.decomposition()])
    627         p = F[0][0]
    628         # When p is odd, and x =/= 1, the conductor is the
smallest p**r such that

/home/bober/sage/local/lib/python2.6/site-
packages/sage/misc/cachefunc.pyc in __call__(self, *args, **kwds)
    240             return cache[key]
    241         else:
--> 242             cache[key] = self.f(self._instance, *args, **kwds)
    243             return cache[key]
    244

/home/bober/sage/local/lib/python2.6/site-
packages/sage/modular/dirichlet.pyc in conductor(self)
    620             20
    621         """
--> 622         if self.modulus() == 1 or self.is_trivial():
    623             return 1
    624         F = arith.factor(self.modulus())

/home/bober/sage/local/lib/python2.6/site-
packages/sage/misc/cachefunc.pyc in __call__(self, *args, **kwds)
    240             return cache[key]
    241         else:
--> 242             cache[key] = self.f(self._instance, *args, **kwds)
    243             return cache[key]
    244

/home/bober/sage/local/lib/python2.6/site-
packages/sage/modular/dirichlet.pyc in is_trivial(self)
   1177             True
   1178         """
-> 1179         return (self.element() == 0)
   1180
   1181     def kernel(self):

/home/bober/sage/local/lib/python2.6/site-
packages/sage/modular/dirichlet.pyc in element(self)
   1531             M    = P._module
   1532             dlog = P._zeta_dlog
-> 1533             v = M([dlog[x] for x in self.values_on_gens()])
   1534             self.__element = v
   1535             return v

KeyError: -1.00000000000000 - 2.63677968348475e-16*I
sage: G[3].is_primitive()
------------------------------------------------------------------------
---
KeyError                                  Traceback (most recent call
last)

/home/bober/.sage/temp/bober/24617/_home_bober__sage_init_sage_0.py in
<module>()

/home/bober/sage/local/lib/python2.6/site-
packages/sage/misc/cachefunc.pyc in __call__(self, *args, **kwds)
    240             return cache[key]
    241         else:
--> 242             cache[key] = self.f(self._instance, *args, **kwds)
    243             return cache[key]
    244

/home/bober/sage/local/lib/python2.6/site-
packages/sage/modular/dirichlet.pyc in is_primitive(self)
   1161             True
   1162         """
-> 1163         return (self.conductor() == self.modulus())
   1164
   1165     @cached_method

/home/bober/sage/local/lib/python2.6/site-
packages/sage/misc/cachefunc.pyc in __call__(self, *args, **kwds)
    240             return cache[key]
    241         else:
--> 242             cache[key] = self.f(self._instance, *args, **kwds)
    243             return cache[key]
    244

/home/bober/sage/local/lib/python2.6/site-
packages/sage/modular/dirichlet.pyc in conductor(self)
    624         F = arith.factor(self.modulus())
    625         if len(F) > 1:
--> 626             return misc.mul([d.conductor() for d in
self.decomposition()])
    627         p = F[0][0]
    628         # When p is odd, and x =/= 1, the conductor is the
smallest p**r such that

/home/bober/sage/local/lib/python2.6/site-
packages/sage/misc/cachefunc.pyc in __call__(self, *args, **kwds)
    240             return cache[key]
    241         else:
--> 242             cache[key] = self.f(self._instance, *args, **kwds)
    243             return cache[key]
    244

/home/bober/sage/local/lib/python2.6/site-
packages/sage/modular/dirichlet.pyc in conductor(self)
    620             20
    621         """
--> 622         if self.modulus() == 1 or self.is_trivial():
    623             return 1
    624         F = arith.factor(self.modulus())

/home/bober/sage/local/lib/python2.6/site-
packages/sage/misc/cachefunc.pyc in __call__(self, *args, **kwds)
    240             return cache[key]
    241         else:
--> 242             cache[key] = self.f(self._instance, *args, **kwds)
    243             return cache[key]
    244

/home/bober/sage/local/lib/python2.6/site-
packages/sage/modular/dirichlet.pyc in is_trivial(self)
   1177             True
   1178         """
-> 1179         return (self.element() == 0)
   1180
   1181     def kernel(self):

/home/bober/sage/local/lib/python2.6/site-
packages/sage/modular/dirichlet.pyc in element(self)
   1531             M    = P._module
   1532             dlog = P._zeta_dlog
-> 1533             v = M([dlog[x] for x in self.values_on_gens()])
   1534             self.__element = v
   1535             return v

KeyError: -1.00000000000000 - 2.63677968348475e-16*I
sage:
}}}

Apply: [attachment:trac_7191_v2.patch]

URL: http://trac.sagemath.org/7191
Reported by: bober
Ticket author(s): Jonathan Bober, Frédéric Chapoton
Reviewer(s): Johan Bosman, Peter Bruin