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

remove attempt to coerce scalar to basering for truediv #39371

Open
wants to merge 2 commits into
base: develop
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# sage.doctest: needs sage.libs.ntl

Check failure on line 1 in src/sage/rings/polynomial/padics/polynomial_padic_capped_relative_dense.py

View workflow job for this annotation

GitHub Actions / test-new

SignalError in doctesting framework

sage: K = Qp(13,7) ## line 43 ## sage: R.<t> = K[] ## line 44 ## sage: R([K(13), K(1)]) ## line 45 ## (1 + O(13^7))*t + 13 + O(13^8) sage: T.<t> = ZZ[] ## line 47 ## sage: R(t + 2) ## line 48 ## (1 + O(13^7))*t + 2 + O(13^7) sage: f = R.zero() ## line 53 ## sage: R(f.monomial_coefficients()) ## line 54 ## 0 sage: R.<x> = PolynomialRing(ZZ) ## line 59 ## sage: f = x + 5 ## line 60 ## sage: S.<y> = PolynomialRing(Qp(5)) ## line 61 ## sage: g2 = S(f) ## line 62 ## sage: 25*g2 ## line 63 ##
"""
`p`-adic Capped Relative Dense Polynomials
"""
Expand Down Expand Up @@ -573,7 +573,7 @@
sage: K(13,7) * a
(13 + O(13^7))*t^4 + (13^2 + O(13^6))*t^2 + 13^2 + O(13^8)
"""
return None
# return None #commented this out to see how broken this is
# The code below has never been tested and is somehow subtly broken.

if self._valaddeds is None:
Expand Down
9 changes: 0 additions & 9 deletions src/sage/rings/polynomial/polynomial_element.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""

Check failure on line 1 in src/sage/rings/polynomial/polynomial_element.pyx

View workflow job for this annotation

GitHub Actions / test-new

SignalError in doctesting framework

sage: R.<x> = ZZ[] ## line 6 ## sage: f = x^5 + 2*x^2 + (-1) ## line 7 ## sage: f == loads(dumps(f)) ## line 8 ## True sage: PolynomialRing(ZZ,'x').objgen() ## line 11 ## (Univariate Polynomial Ring in x over Integer Ring, x) sage: sig_on_count() # check sig_on/off pairings (virtual doctest) ## line 46 ## 0 sage: from sage.rings.polynomial.polynomial_element import is_Polynomial ## line 145 ## sage: R.<x> = ZZ[] ## line 146 ## sage: is_Polynomial(x^3 + x + 1) ## line 147 ## doctest:warning File "<doctest sage.rings.polynomial.polynomial_element.is_Polynomial[2]>", line 1, in <module> is_Polynomial(x**Integer(3) + x + Integer(1)) File "/sage/src/sage/misc/superseded.py", line 138, in deprecation_cython warning(issue_number, message, DeprecationWarning, stacklevel) File "/sage/src/sage/misc/superseded.py", line 180, in warning warn(message, warning_class, stacklevel) File "/usr/lib/python3.10/warnings.py", line 109, in _showwarnmsg sw(msg.message, msg.category, msg.filename, msg.lineno, : DeprecationWarning: the function is_Polynomial is deprecated; use isinstance(x, sage.rings.polynomial.polynomial_element.Polynomial) instead See https://github.com/sagemath/sage/issues/32709 for details. True sage: S.<y> = R[] ## line 152 ## sage: f = y^3 + x*y - 3*x; f ## line 153 ## y^3 + x*y - 3*x sage: is_Polynomial(f) ## line 155 ## True sage: R.<x,y> = QQ[] ## line 162 ## sage: f = y^3 + x*y - 3*x; f ## line 163 ## y^3 + x*y - 3*x sage: is_Polynomial(f) ## line 165 ## False sage: var('x,y') ## line 169 ## (x, y) sage: f = y^3 + x*y - 3*x; f ## line 171 ## y^3 + x*y - 3*x sage: is_Polynomial(f) ## line 173 ## False sage: sig_on_count() # check sig_on/off pairings (virtual doctest) ## line 175 ## 0 sage: R.<y> = QQ['y'] ## line 191 ## sage: S.<x> = R['x'] ## line 192 ## sage: S ## line 193 ## Univariate Polynomial Ring in x over Univariate Polynomial Ring in y over Rational Field sage: f = x*y; f ## line 196 ## y*x sage: type(f) ## line 198 ## <class 'sage.rings.polynomial.polynomial_element.Polynomial_generic_dense'> sage: p = (y+1)^10; p(1) ## line 200 ## 1024 sage: sig_on_count() # check sig_on/off pairings (virtual doctest) ## line 209 ## 0 sage: R.<x> = ZZ[] ## line 219 ## sage: f = x^5 + 2*x^2 + (-1); f ## line 220 ## x^5 + 2*x^2 - 1 sage: f^2 ## line 222 ## x^10 + 4*x^7 - 2*x^5 + 4*x^4 - 4*x^2 + 1 sage: R.<x> = ZZ[ ]; R ## line 228 ## Univariate Polynomial Ring in x over Integer Ring sage: S.<Z> = R[ ]; S ## line 230 ## Univariate Polynomial Ring in Z over Univariate Polynomial Ring in x over Integer Ring sage: f = Z^3 + (x^2-2*x+1)*Z - 3; f ## line 232 ## Z^3 + (x^2 - 2*x + 1)*Z - 3 sage: f*f ## line 234 ## Z^6 + (2*x^2 - 4*x + 2)*Z^4 - 6*Z^3 + (x^4 - 4*x^3 + 6*x^2 - 4*x + 1)*Z^2 + (-6*x^2 + 12*x - 6)*Z + 9 sage: f^3 == f*f*f ## line 236 ## True sage: sig_on_count() # check sig_on/off pairings (virtual doctest) ## line 238 ## 0 sage: R = ZZ['x'] ## line 262 ## sage: p = R([1,2,3,4]) ## line 263 ## sage: q = R([4,-3,2,-1]) ## line 264 ## sage: p + q # indirect doctest ## line 265 ## 3*x^3 + 5*x^2 - x + 5 sage: sig_on_count() # check sig_on/off pairings (virtual doctest) ## line 267 ## 0 sage: R = GF(2)['x']['y'] ## line 294 ## sage: R([0,1]).is_zero() ## line 295 ## False sage: R([0]).is_zero() ## line 297 ## True sage: R([-1]).is_zero() ## line 299 ## False sage: sig_on_count() # check sig_on/off pairings (virtual doctest) ## line 301 ## 0 sage: R.<x> = QQ[] ## line 310 ## sage: (x - 3).is_one() ## line 311 ## False sage: R(1).is_one() ## line 313 ## True sage: R2.<y> = R[] ## line 316 ## sage: R2(x).is_one() ## line 317 ## False sage: R2(1).is_one() ## line 319 ## True sage: R2(-1).is_one() ## line 321 ## False sage: sig_on_count() # check sig_on/off pairings (virtual doctest) ## line 323 ## 0 sage: x = polygen(GF(389)) ## line 342 ## sage: plot(x^2 + 1, rgbcolor=(0,0,1)) # needs sage.plot ## line 343 ## Graphics object consisting of 1 graphics primitive sage: x = polygen(QQ) ## line 345 ## sage: plot(x^2 + 1, rgbcolor=(1,0,0))
Univariate polynomial base class

TESTS::
Expand Down Expand Up @@ -2753,7 +2753,7 @@
ZeroDivisionError: inverse of Mod(0, 5) does not exist

sage: P.<x> = GF(25, 'a')[] # needs sage.rings.finite_rings
sage: x/5 # needs sage.rings.finite_rings

Check failure on line 2756 in src/sage/rings/polynomial/polynomial_element.pyx

View workflow job for this annotation

GitHub Actions / test-new

Failed example:

Failed example:: Got: Traceback (most recent call last): File "/sage/src/sage/doctest/forker.py", line 728, in _run self.compile_and_execute(example, compiler, test.globs) File "/sage/src/sage/doctest/forker.py", line 1152, in compile_and_execute exec(compiled, globs) File "<doctest sage.rings.polynomial.polynomial_element.Polynomial.__truediv__[20]>", line 1, in <module> x/Integer(5) # needs sage.rings.finite_rings File "sage/rings/polynomial/polynomial_element.pyx", line 2773, in sage.rings.polynomial.polynomial_element.Polynomial.__truediv__ return wrapperdescr_fastcall(RingElement.__truediv__, File "sage/cpython/wrapperdescr.pyx", line 104, in sage.cpython.wrapperdescr.wrapperdescr_fastcall return slotdef.wrapper(self, args, slotwrapper.d_wrapped) File "sage/structure/element.pyx", line 1731, in sage.structure.element.Element.__truediv__ return coercion_model.bin_op(left, right, truediv) File "sage/structure/coerce.pyx", line 1230, in sage.structure.coerce.CoercionModel.bin_op return (<Action>action)._act_(y, x) File "sage/categories/action.pyx", line 507, in sage.categories.action.PrecomposedAction._act_ return self._action._act_(g, x) File "sage/categories/action.pyx", line 417, in sage.categories.action.InverseAction._act_ return self._action._act_(~g, x) File "sage/rings/finite_rings/integer_mod.pyx", line 2859, in sage.rings.finite_rings.integer_mod.IntegerMod_int.__invert__ raise ZeroDivisionError(f"inverse of Mod({self}, {self._modulus.sageInteger}) does not exist") ZeroDivisionError: inverse of Mod(0, 5) does not exist
Traceback (most recent call last):
...
ZeroDivisionError: division by zero in finite field
Expand All @@ -2767,15 +2767,6 @@
if have_same_parent(left, right):
return (<Element>left)._div_(right)

# Try division of polynomial by a scalar
if isinstance(left, Polynomial):
R = (<Polynomial>left)._parent._base
try:
x = R.coerce(right)
return left * ~x
except TypeError:
pass

# Delegate to coercion model. The line below is basically
# RingElement.__truediv__(left, right), except that it also
# works if left is not of type RingElement.
Expand Down
Loading