From d8d3eda712c9b8eba85fed818ef385e56ddb16b3 Mon Sep 17 00:00:00 2001 From: zabrocki Date: Sun, 1 Nov 2015 20:07:07 -0500 Subject: [PATCH] additions to NCSF/QSym/Sym/NCSym/NCSymD to ensure that MRO errors are not triggered --- src/sage/combinat/ncsf_qsym/ncsf.py | 6 +++++- src/sage/combinat/ncsf_qsym/qsym.py | 7 +++++-- src/sage/combinat/ncsym/dual.py | 6 ++++++ src/sage/combinat/ncsym/ncsym.py | 6 ++++++ src/sage/combinat/sf/sf.py | 12 +++++------- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/sage/combinat/ncsf_qsym/ncsf.py b/src/sage/combinat/ncsf_qsym/ncsf.py index d6ba56f6478..15422a928e7 100644 --- a/src/sage/combinat/ncsf_qsym/ncsf.py +++ b/src/sage/combinat/ncsf_qsym/ncsf.py @@ -32,6 +32,7 @@ from sage.functions.other import factorial from sage.categories.realizations import Category_realization_of_parent from sage.categories.rings import Rings +from sage.categories.fields import Fields from sage.categories.graded_hopf_algebras import GradedHopfAlgebras from sage.combinat.composition import Compositions from sage.combinat.free_module import CombinatorialFreeModule @@ -401,9 +402,12 @@ def __init__(self, R): r""" TESTS:: + sage: NCSF1 = NonCommutativeSymmetricFunctions(FiniteField(23)) + sage: NCSF2 = NonCommutativeSymmetricFunctions(Integers(23)) sage: TestSuite(NonCommutativeSymmetricFunctions(QQ)).run() """ - assert(R in Rings()) + # change the line below to assert(R in Rings()) once MRO issues from #15536, #15475 are resolved + assert(R in Fields() or R in Rings()) # side effect of this statement assures MRO exists for R self._base = R # Won't be needed once CategoryObject won't override base_ring Parent.__init__(self, category = GradedHopfAlgebras(R).WithRealizations()) diff --git a/src/sage/combinat/ncsf_qsym/qsym.py b/src/sage/combinat/ncsf_qsym/qsym.py index 26568000798..2434430c93e 100644 --- a/src/sage/combinat/ncsf_qsym/qsym.py +++ b/src/sage/combinat/ncsf_qsym/qsym.py @@ -65,8 +65,8 @@ from sage.misc.bindable_class import BindableClass from sage.categories.graded_hopf_algebras import GradedHopfAlgebras -from sage.categories.all import CommutativeRings from sage.categories.rings import Rings +from sage.categories.fields import Fields from sage.categories.realizations import Category_realization_of_parent from sage.structure.parent import Parent from sage.structure.unique_representation import UniqueRepresentation @@ -529,9 +529,12 @@ def __init__(self, R): sage: QuasiSymmetricFunctions(QQ) Quasisymmetric functions over the Rational Field + sage: QSym1 = QuasiSymmetricFunctions(FiniteField(23)) + sage: QSym2 = QuasiSymmetricFunctions(Integers(23)) sage: TestSuite(QuasiSymmetricFunctions(QQ)).run() """ - assert R in Rings() + # change the line below to assert(R in Rings()) once MRO issues from #15536, #15475 are resolved + assert(R in Fields() or R in Rings()) # side effect of this statement assures MRO exists for R self._base = R # Won't be needed once CategoryObject won't override base_ring category = GradedHopfAlgebras(R) # TODO: .Commutative() self._category = category diff --git a/src/sage/combinat/ncsym/dual.py b/src/sage/combinat/ncsym/dual.py index 3a01c975a1a..11f6a79be99 100644 --- a/src/sage/combinat/ncsym/dual.py +++ b/src/sage/combinat/ncsym/dual.py @@ -17,6 +17,8 @@ from sage.structure.parent import Parent from sage.structure.unique_representation import UniqueRepresentation from sage.categories.graded_hopf_algebras import GradedHopfAlgebras +from sage.categories.rings import Rings +from sage.categories.fields import Fields from sage.combinat.ncsym.bases import NCSymDualBases, NCSymBasis_abstract from sage.combinat.partition import Partition @@ -39,8 +41,12 @@ def __init__(self, R): EXAMPLES:: + sage: NCSymD1 = SymmetricFunctionsNonCommutingVariablesDual(FiniteField(23)) + sage: NCSymD2 = SymmetricFunctionsNonCommutingVariablesDual(Integers(23)) sage: TestSuite(SymmetricFunctionsNonCommutingVariables(QQ).dual()).run() """ + # change the line below to assert(R in Rings()) once MRO issues from #15536, #15475 are resolved + assert(R in Fields() or R in Rings()) # side effect of this statement assures MRO exists for R self._base = R # Won't be needed once CategoryObject won't override base_ring category = GradedHopfAlgebras(R) # TODO: .Commutative() Parent.__init__(self, category=category.WithRealizations()) diff --git a/src/sage/combinat/ncsym/ncsym.py b/src/sage/combinat/ncsym/ncsym.py index 27a63cc7921..6cdd45766b1 100644 --- a/src/sage/combinat/ncsym/ncsym.py +++ b/src/sage/combinat/ncsym/ncsym.py @@ -18,6 +18,8 @@ from sage.structure.parent import Parent from sage.structure.unique_representation import UniqueRepresentation from sage.categories.graded_hopf_algebras import GradedHopfAlgebras +from sage.categories.rings import Rings +from sage.categories.fields import Fields from sage.functions.other import factorial from sage.combinat.free_module import CombinatorialFreeModule @@ -282,8 +284,12 @@ def __init__(self, R): EXAMPLES:: + sage: NCSym1 = SymmetricFunctionsNonCommutingVariables(FiniteField(23)) + sage: NCSym2 = SymmetricFunctionsNonCommutingVariables(Integers(23)) sage: TestSuite(SymmetricFunctionsNonCommutingVariables(QQ)).run() """ + # change the line below to assert(R in Rings()) once MRO issues from #15536, #15475 are resolved + assert(R in Fields() or R in Rings()) # side effect of this statement assures MRO exists for R self._base = R # Won't be needed once CategoryObject won't override base_ring category = GradedHopfAlgebras(R) # TODO: .Commutative() Parent.__init__(self, category = category.WithRealizations()) diff --git a/src/sage/combinat/sf/sf.py b/src/sage/combinat/sf/sf.py index 895aad981c7..22d587d6611 100644 --- a/src/sage/combinat/sf/sf.py +++ b/src/sage/combinat/sf/sf.py @@ -21,9 +21,9 @@ #***************************************************************************** from sage.structure.parent import Parent from sage.structure.unique_representation import UniqueRepresentation -from sage.categories.rings import Rings from sage.categories.graded_hopf_algebras import GradedHopfAlgebras from sage.categories.fields import Fields +from sage.categories.rings import Rings from sage.combinat.partition import Partitions from sage.combinat.free_module import CombinatorialFreeModule from sage.rings.rational_field import QQ @@ -829,15 +829,13 @@ def __init__(self, R): TESTS:: + sage: Sym1 = SymmetricFunctions(FiniteField(23)) + sage: Sym2 = SymmetricFunctions(Integers(23)) sage: TestSuite(Sym).run() """ - assert(R in Rings()) - # FIXME: We just automatically check that the base ring is a field to - # prevent category refinement during construction of the category, - # thus preventing the MRO issues noted in #15536, #15475 (and likely others). - # Thus fix the MRO/category-refinement issue and remove the line below. - R in Fields() + # change the line below to assert(R in Rings()) once MRO issues from #15536, #15475 are resolved + assert(R in Fields() or R in Rings()) # side effect of this statement assures MRO exists for R self._base = R # Won't be needed when CategoryObject won't override anymore base_ring Parent.__init__(self, category = GradedHopfAlgebras(R).WithRealizations())