Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for using the modularized passagemath distributions #15

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions _doctest_environment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Toplevel for doctesting with passagemath

from sage.all__sagemath_modules import *
52 changes: 25 additions & 27 deletions dirichlet_conrey.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,31 @@

from libc.stdlib cimport malloc, free

from sage.all import (factor,
primitive_root,
IntegerModRing,
euler_phi,
gcd,
lcm,
is_prime,
DirichletGroup,
vector,
Integer,
power_mod,
prod,
crt,
mod,
inverse_mod,
multiplicative_order,
pi,
RR,
CC,
ZZ,
diagonal_matrix,
Mod,
round,
imag)

from sage.arith.functions import lcm
from sage.arith.misc import CRT as crt
from sage.arith.misc import GCD as gcd
from sage.arith.misc import euler_phi
from sage.arith.misc import factor
from sage.arith.misc import inverse_mod
from sage.arith.misc import is_prime
from sage.arith.misc import power_mod
from sage.arith.misc import primitive_root
from sage.functions.other import imag
from sage.matrix.special import diagonal_matrix
from sage.misc.functional import multiplicative_order
from sage.misc.functional import round
from sage.misc.misc_c import prod
from sage.modular.dirichlet import DirichletCharacter
from sage.modular.dirichlet import DirichletGroup
from sage.modules.free_module_element import free_module_element as vector
from sage.rings.cc import CC
from sage.rings.finite_rings.integer_mod import Mod
from sage.rings.finite_rings.integer_mod_ring import IntegerModRing
from sage.rings.integer import Integer
from sage.rings.integer_ring import Z as ZZ
from sage.rings.real_mpfr import RR
from sage.structure.richcmp import richcmp
from sage.symbolic.constants import pi

import cmath

Expand Down Expand Up @@ -695,7 +693,7 @@ cdef class DirichletGroup_conrey:
while not traces_unique and trace_size <= q:
traces_lists = []
for orbit in orbits:
order = multiplicative_order(mod(orbit[0], q))
order = multiplicative_order(Mod(orbit[0], q))
traces = [int(round(sum([self.chi(chi, n) for chi in orbit]).real))*(N/len(orbit)) for n in range(1, trace_size)]
traces_lists.append((order, traces, orbit))

Expand Down Expand Up @@ -1358,7 +1356,7 @@ cdef class DirichletCharacter_conrey:
sage: all(chi.multiplicative_order() == chi.sage_character().multiplicative_order() for chi in G)
True
"""
return multiplicative_order(mod(self._n, self._parent.q))
return multiplicative_order(Mod(self._n, self._parent.q))

cpdef parent(self):
return self._parent
Expand Down
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[build-system]
requires = [
"setuptools",
"cython",
"numpy",
"passagemath-environment",
]
build-backend = "setuptools.build_meta"
25 changes: 18 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@
from numpy import get_include
from distutils.sysconfig import get_python_inc

if not 'SAGE_ROOT' in os.environ:
print(" ERROR: The environment variable SAGE_ROOT must be defined.")
sys.exit(1)
else:
SAGE_ROOT = os.environ['SAGE_ROOT']
SAGE_LOCAL = os.environ['SAGE_LOCAL']
SAGE_SRC = os.environ['SAGE_SRC']
try:
from sage.env import SAGE_ROOT, SAGE_LOCAL, SAGE_SRC
except ImportError:
if not 'SAGE_ROOT' in os.environ:
print(" ERROR: The environment variable SAGE_ROOT must be defined.")
sys.exit(1)
else:
SAGE_ROOT = os.environ['SAGE_ROOT']
SAGE_LOCAL = os.environ['SAGE_LOCAL']
SAGE_SRC = os.environ['SAGE_SRC']

extra_link_args = ['-L' + SAGE_LOCAL + '/lib']
extra_compile_args = ['-w', '-O2']
Expand Down Expand Up @@ -50,6 +53,14 @@
url='http://github.com/jwbober/conrey-dirichlet-characters',
ext_modules = ext_modules,
include_dirs = include_dirs,
extras_require={
'passagemath': [
'passagemath-modules',
'passagemath-repl',
'passagemath-schemes',
'passagemath-symbolics',
],
},
cmdclass = {'build_ext' : build_ext})


19 changes: 19 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# tox -c tox-passagemath.ini
[tox]
envlist = passagemath

[testenv:.pkg]
passenv =
CPATH
LIBRARY_PATH

[testenv:passagemath]
usedevelop = True
extras = passagemath

setenv =
# For access to _doctest_environment.py
PYTHONPATH=.

commands =
sage -tp --force-lib --environment=_doctest_environment dirichlet_conrey.pyx