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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing one bug in the use of valuation #36882

Merged
merged 2 commits into from
Dec 26, 2023
Merged
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
11 changes: 10 additions & 1 deletion src/sage/categories/discrete_valuation.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,22 +147,31 @@ def quo_rem(self, other):
Return the quotient and remainder for Euclidean division
of ``self`` by ``other``.

TESTS::
EXAMPLES::

sage: R.<q> = GF(5)[[]]
sage: (q^2 + q).quo_rem(q)
(1 + q, 0)
sage: (q + 1).quo_rem(q^2)
(0, 1 + q)

TESTS::

sage: q.quo_rem(0)
Traceback (most recent call last):
...
ZeroDivisionError: Euclidean division by the zero element not defined

sage: L = PowerSeriesRing(QQ, 't')
sage: t = L.gen()
sage: F = algebras.Free(L, ['A', 'B'])
sage: A, B = F.gens()
sage: f = t*A+t**2*B/2
"""
if not other:
raise ZeroDivisionError("Euclidean division by the zero element not defined")
P = self.parent()
other = P(other)
if self.valuation() >= other.valuation():
return P(self / other), P.zero()
else:
Expand Down
9 changes: 8 additions & 1 deletion src/sage/modules/with_basis/indexed_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ from sage.misc.superseded import deprecation
from sage.typeset.ascii_art import AsciiArt, empty_ascii_art, ascii_art
from sage.typeset.unicode_art import UnicodeArt, empty_unicode_art, unicode_art
from sage.data_structures.blas_dict cimport add, negate, scal, axpy
from sage.categories.modules import _Fields


cdef class IndexedFreeModuleElement(ModuleElement):
Expand Down Expand Up @@ -958,6 +959,12 @@ cdef class IndexedFreeModuleElement(ModuleElement):
Traceback (most recent call last):
...
TypeError: unsupported operand type(s) for /: 'str' and 'CombinatorialFreeModule_with_category.element_class'

sage: L = LazyPowerSeriesRing(QQ, 't')
sage: t = L.gen()
sage: F = algebras.Free(L, ['A', 'B'])
sage: A, B = F.gens()
sage: f = t*A + t**2*B/2
"""
if not isinstance(left, IndexedFreeModuleElement):
return NotImplemented
Expand All @@ -966,7 +973,7 @@ cdef class IndexedFreeModuleElement(ModuleElement):
F = self._parent
B = self.base_ring()
D = self._monomial_coefficients
if not B.is_field():
if B not in _Fields:
return type(self)(F, {k: c._divide_if_possible(x)
for k, c in D.items()})

Expand Down
Loading