Skip to content

Commit

Permalink
Trac #22662: Fold farey.pxd into farey_symbol.pyx
Browse files Browse the repository at this point in the history
Unlike other `.pxd` files, the file `farey.pxd` is ''not'' meant as
public header. For this reason, we move its contents to the file
`farey_symbol.pyx`, which is the only place where it is used.

We also fix a typo `__deallocpp__` causing a memory leak.

URL: https://trac.sagemath.org/22662
Reported by: jdemeyer
Ticket author(s): Jeroen Demeyer
Reviewer(s): Frédéric Chapoton
  • Loading branch information
Release Manager authored and vbraun committed Apr 5, 2017
2 parents d232cd2 + 8e5db1e commit 6f6a086
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 75 deletions.
59 changes: 0 additions & 59 deletions src/sage/modular/arithgroup/farey.pxd

This file was deleted.

76 changes: 63 additions & 13 deletions src/sage/modular/arithgroup/farey_symbol.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,23 @@ for speed.
# http://www.gnu.org/licenses/
#*****************************************************************************

from __future__ import absolute_import, division

from cpython.object cimport PyObject_RichCompare
from itertools import groupby

include "cysignals/signals.pxi"
include 'sage/ext/cdefs.pxi'

from .farey cimport *
from sage.libs.gmpxx cimport *

from sage.rings.all import CC, RR
from sage.rings.integer cimport Integer
from sage.rings.infinity import infinity
from congroup_gammaH import is_GammaH
from congroup_gamma1 import is_Gamma1
from congroup_gamma0 import is_Gamma0
from congroup_gamma import is_Gamma
from congroup_sl2z import SL2Z
from .congroup_gammaH import is_GammaH
from .congroup_gamma1 import is_Gamma1
from .congroup_gamma0 import is_Gamma0
from .congroup_gamma import is_Gamma
from .congroup_sl2z import SL2Z
from sage.modular.cusps import Cusp

from sage.plot.all import Graphics
Expand All @@ -41,9 +46,54 @@ from sage.plot.all import hyperbolic_arc, hyperbolic_triangle, text
from sage.misc.latex import latex
from sage.misc.lazy_attribute import lazy_attribute
from sage.misc.cachefunc import cached_method
from cpython.object cimport PyObject_RichCompare
from sage.structure.sage_object cimport richcmp_not_equal
from itertools import groupby


cdef extern from "sage/modular/arithgroup/sl2z.cpp":
cppclass cpp_SL2Z "SL2Z":
mpz_class a, b, c, d
cpp_SL2Z(int, int, int, int)
cpp_SL2Z(mpz_class, mpz_class, mpz_class, mpz_class)
mpz_class a()
mpz_class b()
mpz_class c()
mpz_class d()

cdef extern from "sage/modular/arithgroup/farey.cpp":
cppclass is_element_Gamma0:
is_element_Gamma0(int)
cppclass is_element_Gamma1:
is_element_Gamma1(int)
cppclass is_element_Gamma:
is_element_Gamma(int)
cppclass is_element_GammaH:
is_element_GammaH(int, object)
cppclass cpp_farey "FareySymbol":
cpp_farey()
cpp_farey(object)
cpp_farey(object, is_element_Gamma*)
cpp_farey(object, is_element_Gamma0*)
cpp_farey(object, is_element_Gamma1*)
cpp_farey(object, is_element_GammaH*)
size_t genus()
size_t index()
size_t level()
size_t nu2()
size_t nu3()
object is_element(mpz_t, mpz_t, mpz_t, mpz_t)
object word_problem(mpz_t, mpz_t, mpz_t, mpz_t, cpp_SL2Z *)
size_t get_cusp_class(mpz_t, mpz_t)
object get_cusps()
object get_cusp_widths()
object get_transformation_to_cusp(mpz_t, mpz_t)
object get_fractions()
object get_coset()
object get_generators()
object get_pairings()
object get_paired_sides()
object get_pairing_matrices()
object dumps()


cdef class Farey:
r"""
Expand Down Expand Up @@ -195,14 +245,14 @@ cdef class Farey:
self.this_ptr = new cpp_farey(group)
sig_off()

def __deallocpp__(self):
def __dealloc__(self):
r"""
Remove reference to FareySymbol::
Remove reference to FareySymbol.
sage: F = FareySymbol(Gamma0(23))
TESTS::
sage: F = FareySymbol(Gamma0(23))
sage: del F
"""
del self.this_ptr

Expand Down
6 changes: 3 additions & 3 deletions src/sage_setup/find.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ def find_extra_files(packages, src_dir, cythonized_dir, special_filenames=[]):
sage: from sage_setup.find import find_extra_files
sage: from sage.env import SAGE_SRC, SAGE_CYTHONIZED
sage: find_extra_files(["sage.modular.arithgroup"], SAGE_SRC, SAGE_CYTHONIZED)
[('sage/modular/arithgroup',
['.../src/sage/modular/arithgroup/farey.pxd', ...farey_symbol.h...])]
sage: find_extra_files(["sage.ext.interpreters"], SAGE_SRC, SAGE_CYTHONIZED)
[('sage/ext/interpreters',
['.../src/sage/ext/interpreters/wrapper_cdf.pxd', ...wrapper_cdf.h...])]
"""
data_files = []

Expand Down

0 comments on commit 6f6a086

Please sign in to comment.