-
-
Notifications
You must be signed in to change notification settings - Fork 482
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trac #32413: Remove unnecessary uses of SR and symbolic functions in …
…sage.categories, sage.coding `git grep -E '[.](symbolic|calculus|functions).*import' src/sage/coding` reveals a number of calls to the symbolic calculus subsystem of Sage that can be avoided, similar to what is done in #32411 URL: https://trac.sagemath.org/32413 Reported by: mkoeppe Ticket author(s): Frédéric Chapoton Reviewer(s): Matthias Koeppe
- Loading branch information
Showing
11 changed files
with
48 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
r""" | ||
Examples of finite enumerated sets | ||
""" | ||
#***************************************************************************** | ||
# **************************************************************************** | ||
# Copyright (C) 2009 Florent Hivert <[email protected]> | ||
# | ||
# Distributed under the terms of the GNU General Public License (GPL) | ||
# http://www.gnu.org/licenses/ | ||
#****************************************************************************** | ||
# https://www.gnu.org/licenses/ | ||
# ***************************************************************************** | ||
from sage.structure.parent import Parent | ||
from sage.structure.unique_representation import UniqueRepresentation | ||
from sage.categories.finite_enumerated_sets import FiniteEnumeratedSets | ||
from sage.rings.integer import Integer | ||
from sage.rings.integer_ring import IntegerRing | ||
from sage.functions.other import sqrt | ||
|
||
|
||
class Example(UniqueRepresentation, Parent): | ||
r""" | ||
|
@@ -75,8 +75,9 @@ def __init__(self): | |
Category of facade finite enumerated sets | ||
sage: TestSuite(C).run() | ||
""" | ||
self._set = [Integer(_) for _ in [1,2,3]] | ||
Parent.__init__(self, facade = IntegerRing(), category = FiniteEnumeratedSets()) | ||
self._set = [Integer(_) for _ in [1, 2, 3]] | ||
Parent.__init__(self, facade=IntegerRing(), | ||
category=FiniteEnumeratedSets()) | ||
|
||
def _repr_(self): | ||
""" | ||
|
@@ -109,9 +110,10 @@ def __iter__(self): | |
""" | ||
return iter(self._set) | ||
|
||
|
||
class IsomorphicObjectOfFiniteEnumeratedSet(UniqueRepresentation, Parent): | ||
|
||
def __init__(self, ambient = Example()): | ||
def __init__(self, ambient=Example()): | ||
""" | ||
TESTS:: | ||
|
@@ -123,7 +125,8 @@ def __init__(self, ambient = Example()): | |
sage: TestSuite(C).run() | ||
""" | ||
self._ambient = ambient | ||
Parent.__init__(self, facade = IntegerRing(), category = FiniteEnumeratedSets().IsomorphicObjects()) | ||
Parent.__init__(self, facade=IntegerRing(), | ||
category=FiniteEnumeratedSets().IsomorphicObjects()) | ||
|
||
def ambient(self): | ||
""" | ||
|
@@ -156,7 +159,7 @@ def lift(self, x): | |
sage: C.lift(9) | ||
3 | ||
""" | ||
return sqrt(x) | ||
return x.sqrt() | ||
|
||
def retract(self, x): | ||
""" | ||
|
8 changes: 4 additions & 4 deletions
8
src/sage/categories/examples/graded_connected_hopf_algebras_with_basis.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
r""" | ||
Examples of graded connected Hopf algebras with basis | ||
""" | ||
#***************************************************************************** | ||
# **************************************************************************** | ||
# Copyright (C) 2015 Jean-Baptiste Priez <[email protected]> | ||
# | ||
# Distributed under the terms of the GNU General Public License (GPL) | ||
# http://www.gnu.org/licenses/ | ||
#***************************************************************************** | ||
# https://www.gnu.org/licenses/ | ||
# **************************************************************************** | ||
|
||
from sage.categories.graded_hopf_algebras_with_basis import GradedHopfAlgebrasWithBasis | ||
from sage.combinat.free_module import CombinatorialFreeModule | ||
from sage.functions.other import binomial | ||
from sage.arith.misc import binomial | ||
from sage.misc.cachefunc import cached_method | ||
from sage.sets.non_negative_integers import NonNegativeIntegers | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,19 +7,19 @@ | |
- David Lucas, ported the original implementation in Sage | ||
""" | ||
|
||
#***************************************************************************** | ||
# **************************************************************************** | ||
# Copyright (C) 2015 David Lucas <[email protected]> | ||
# 2015 Johan S. R. Nielsen <[email protected]> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 2 of the License, or | ||
# (at your option) any later version. | ||
# http://www.gnu.org/licenses/ | ||
#***************************************************************************** | ||
# https://www.gnu.org/licenses/ | ||
# **************************************************************************** | ||
|
||
|
||
from sage.functions.other import ceil, binomial | ||
from sage.arith.misc import binomial | ||
from sage.matrix.constructor import matrix | ||
from sage.misc.misc_c import prod | ||
|
||
|
@@ -68,7 +68,7 @@ def _monomial_list(maxdeg, l, wy): | |
EXAMPLES:: | ||
sage: from sage.coding.guruswami_sudan.interpolation import _monomial_list | ||
sage: _monomial_list(8, 1, 3) | ||
sage: list(_monomial_list(8, 1, 3)) | ||
[(0, 0), | ||
(1, 0), | ||
(2, 0), | ||
|
@@ -83,11 +83,10 @@ def _monomial_list(maxdeg, l, wy): | |
(3, 1), | ||
(4, 1)] | ||
""" | ||
monomials = [] | ||
for y in range(0, l+1): | ||
for x in range(0, ceil(maxdeg - y*wy)): | ||
monomials.append((x, y)) | ||
return monomials | ||
for y in range(l + 1): | ||
for x in range(maxdeg - y * wy): | ||
yield (x, y) | ||
|
||
|
||
def _interpolation_matrix_given_monomials(points, s, monomials): | ||
r""" | ||
|
@@ -216,10 +215,11 @@ def _interpolation_matrix_problem(points, tau, parameters, wy): | |
) | ||
""" | ||
s, l = parameters[0], parameters[1] | ||
monomials = _monomial_list(_interpolation_max_weighted_deg(len(points), tau, s), l, wy) | ||
monomials = list(_monomial_list(_interpolation_max_weighted_deg(len(points), tau, s), l, wy)) | ||
M = _interpolation_matrix_given_monomials(points, s, monomials) | ||
return (M, monomials) | ||
|
||
|
||
def gs_interpolation_linalg(points, tau, parameters, wy): | ||
r""" | ||
Compute an interpolation polynomial Q(x,y) for the Guruswami-Sudan algorithm | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,19 +15,21 @@ | |
- :class:`ReedMullerVectorEncoder`, an encoder with a vectorial message space (for both the two code classes) | ||
- :class:`ReedMullerPolynomialEncoder`, an encoder with a polynomial message space (for both the code classes) | ||
""" | ||
#***************************************************************************** | ||
# **************************************************************************** | ||
# Copyright (C) 2016 Parthasarathi Panda <[email protected]> | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 2 of the License, or | ||
# (at your option) any later version. | ||
# http://www.gnu.org/licenses/ | ||
#***************************************************************************** | ||
# https://www.gnu.org/licenses/ | ||
# **************************************************************************** | ||
|
||
from operator import mul | ||
from functools import reduce | ||
|
||
from sage.matrix.constructor import matrix | ||
from sage.functions.other import binomial | ||
from sage.arith.misc import binomial | ||
from sage.coding.linear_code import AbstractLinearCode, LinearCodeSyndromeDecoder | ||
from sage.coding.encoder import Encoder | ||
from sage.combinat.subset import Subsets | ||
|
@@ -38,7 +40,6 @@ | |
from sage.modules.free_module_element import vector | ||
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing | ||
from sage.misc.cachefunc import cached_method | ||
from functools import reduce | ||
|
||
|
||
def _binomial_sum(n, k): | ||
|