Skip to content
Open
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
40 changes: 40 additions & 0 deletions src/sage/categories/rings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,46 @@
sage: R.ideal()
Principal ideal (0) of Univariate Polynomial Ring in x over Rational Field

Check that we can create the ideal even if no gcd method is implemented::

sage: from sage.structure.element import Element
sage: class MyRingElement(Element):
....: def __init__(self, parent, x):
....: Element.__init__(self, parent)
....: self._x = parent._K(x)
....: def _repr_(self):
....: return str(self._x)
....: def _add_(self, other):
....: P = self.parent()
....: return P.element_class(P, self._x + other._x)
....: def _mul_(self, other):
....: return P.element_class(P, self._x * other._x)

sage: class MyRing(Parent):
....: def __init__(self):
....: R.<x,y> = PolynomialRing(QQ)
....: self._K = R.quotient(x^2+y^2+1)
....: category = PrincipalIdealDomains()
....: Parent.__init__(self, base=QQ, category=category)
....: def _repr_(self):
....: return "Non-Euclidean principal ideal domain"
....: Element = MyRingElement

sage: R = MyRing()
sage: R.ideal(R(3))
Principal ideal (3) of Non-Euclidean principal ideal domain

sage: R.ideal(R(2), R(3))

Check failure on line 1085 in src/sage/categories/rings.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, new)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 733, in _run self.compile_and_execute(example, compiler, test.globs) File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 1157, in compile_and_execute exec(compiled, globs) File "<doctest sage.categories.rings.Rings.ParentMethods.ideal[19]>", line 1, in <module> R.ideal(R(Integer(2)), R(Integer(3))) File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/categories/rings.py", line 1161, in ideal g = g.gcd(h) ^^^^^ File "sage/structure/element.pyx", line 495, in sage.structure.element.Element.__getattr__ return self.getattr_from_category(name) File "sage/structure/element.pyx", line 508, in sage.structure.element.Element.getattr_from_category return getattr_from_other_class(self, cls, name) File "sage/cpython/getattr.pyx", line 358, in sage.cpython.getattr.getattr_from_other_class raise AttributeError(dummy_error_message) AttributeError: 'MyRing_with_category.element_class' object has no attribute 'category_for'

Check failure on line 1085 in src/sage/categories/rings.py

View workflow job for this annotation

GitHub Actions / test-long (src/sage/[a-f]*)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/sage/src/sage/doctest/forker.py", line 733, in _run self.compile_and_execute(example, compiler, test.globs) File "/sage/src/sage/doctest/forker.py", line 1157, in compile_and_execute exec(compiled, globs) File "<doctest sage.categories.rings.Rings.ParentMethods.ideal[19]>", line 1, in <module> R.ideal(R(Integer(2)), R(Integer(3))) File "/sage/src/sage/categories/rings.py", line 1161, in ideal g = g.gcd(h) ^^^^^ File "sage/structure/element.pyx", line 495, in sage.structure.element.Element.__getattr__ File "sage/structure/element.pyx", line 508, in sage.structure.element.Element.getattr_from_category File "sage/cpython/getattr.pyx", line 358, in sage.cpython.getattr.getattr_from_other_class AttributeError: 'MyRing_with_category.element_class' object has no attribute 'category_for'

Check failure on line 1085 in src/sage/categories/rings.py

View workflow job for this annotation

GitHub Actions / Conda (macos, Python 3.11, all)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.11/site-packages/sage/doctest/forker.py", line 733, in _run self.compile_and_execute(example, compiler, test.globs) File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.11/site-packages/sage/doctest/forker.py", line 1157, in compile_and_execute exec(compiled, globs) File "<doctest sage.categories.rings.Rings.ParentMethods.ideal[19]>", line 1, in <module> R.ideal(R(Integer(2)), R(Integer(3))) File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.11/site-packages/sage/categories/rings.py", line 1161, in ideal g = g.gcd(h) ^^^^^ File "sage/structure/element.pyx", line 495, in sage.structure.element.Element.__getattr__ return self.getattr_from_category(name) File "sage/structure/element.pyx", line 508, in sage.structure.element.Element.getattr_from_category return getattr_from_other_class(self, cls, name) File "sage/cpython/getattr.pyx", line 358, in sage.cpython.getattr.getattr_from_other_class raise AttributeError(dummy_error_message) AttributeError: 'MyRing_with_category.element_class' object has no attribute 'gcd'

Check failure on line 1085 in src/sage/categories/rings.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.11, all)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/usr/share/miniconda/envs/sage-dev/lib/python3.11/site-packages/sage/doctest/forker.py", line 733, in _run self.compile_and_execute(example, compiler, test.globs) File "/usr/share/miniconda/envs/sage-dev/lib/python3.11/site-packages/sage/doctest/forker.py", line 1157, in compile_and_execute exec(compiled, globs) File "<doctest sage.categories.rings.Rings.ParentMethods.ideal[19]>", line 1, in <module> R.ideal(R(Integer(2)), R(Integer(3))) File "/usr/share/miniconda/envs/sage-dev/lib/python3.11/site-packages/sage/categories/rings.py", line 1161, in ideal g = g.gcd(h) ^^^^^ File "sage/structure/element.pyx", line 495, in sage.structure.element.Element.__getattr__ return self.getattr_from_category(name) File "sage/structure/element.pyx", line 508, in sage.structure.element.Element.getattr_from_category return getattr_from_other_class(self, cls, name) File "sage/cpython/getattr.pyx", line 358, in sage.cpython.getattr.getattr_from_other_class raise AttributeError(dummy_error_message) AttributeError: 'MyRing_with_category.element_class' object has no attribute 'gcd'

Check failure on line 1085 in src/sage/categories/rings.py

View workflow job for this annotation

GitHub Actions / Conda (macos, Python 3.12, all)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 733, in _run self.compile_and_execute(example, compiler, test.globs) File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 1157, in compile_and_execute exec(compiled, globs) File "<doctest sage.categories.rings.Rings.ParentMethods.ideal[19]>", line 1, in <module> R.ideal(R(Integer(2)), R(Integer(3))) File "/Users/runner/miniconda3/envs/sage-dev/lib/python3.12/site-packages/sage/categories/rings.py", line 1161, in ideal g = g.gcd(h) ^^^^^ File "sage/structure/element.pyx", line 495, in sage.structure.element.Element.__getattr__ return self.getattr_from_category(name) File "sage/structure/element.pyx", line 508, in sage.structure.element.Element.getattr_from_category return getattr_from_other_class(self, cls, name) File "sage/cpython/getattr.pyx", line 358, in sage.cpython.getattr.getattr_from_other_class raise AttributeError(dummy_error_message) AttributeError: 'MyRing_with_category.element_class' object has no attribute 'category_for'

Check failure on line 1085 in src/sage/categories/rings.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, all)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 733, in _run self.compile_and_execute(example, compiler, test.globs) File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/doctest/forker.py", line 1157, in compile_and_execute exec(compiled, globs) File "<doctest sage.categories.rings.Rings.ParentMethods.ideal[19]>", line 1, in <module> R.ideal(R(Integer(2)), R(Integer(3))) File "/usr/share/miniconda/envs/sage-dev/lib/python3.12/site-packages/sage/categories/rings.py", line 1161, in ideal g = g.gcd(h) ^^^^^ File "sage/structure/element.pyx", line 495, in sage.structure.element.Element.__getattr__ return self.getattr_from_category(name) File "sage/structure/element.pyx", line 508, in sage.structure.element.Element.getattr_from_category return getattr_from_other_class(self, cls, name) File "sage/cpython/getattr.pyx", line 358, in sage.cpython.getattr.getattr_from_other_class raise AttributeError(dummy_error_message) AttributeError: 'MyRing_with_category.element_class' object has no attribute 'category_for'

Check failure on line 1085 in src/sage/categories/rings.py

View workflow job for this annotation

GitHub Actions / Conda (ubuntu, Python 3.12, all, editable)

Failed example:

Failed example:: Exception raised: Traceback (most recent call last): File "/home/runner/work/sage/sage/src/sage/doctest/forker.py", line 733, in _run self.compile_and_execute(example, compiler, test.globs) File "/home/runner/work/sage/sage/src/sage/doctest/forker.py", line 1157, in compile_and_execute exec(compiled, globs) File "<doctest sage.categories.rings.Rings.ParentMethods.ideal[19]>", line 1, in <module> R.ideal(R(Integer(2)), R(Integer(3))) File "/home/runner/work/sage/sage/src/sage/categories/rings.py", line 1161, in ideal g = g.gcd(h) ^^^^^ File "sage/structure/element.pyx", line 495, in sage.structure.element.Element.__getattr__ File "sage/structure/element.pyx", line 508, in sage.structure.element.Element.getattr_from_category File "sage/cpython/getattr.pyx", line 358, in sage.cpython.getattr.getattr_from_other_class AttributeError: 'MyRing_with_category.element_class' object has no attribute 'category_for'

Compare with::

sage: R.<x,y> = PolynomialRing(QQ)
sage: K = R.quotient(x^2+y^2+1)
sage: K._refine_category_(PrincipalIdealDomains())
sage: K.ideal(2, 3)
Ideal (2, 3) of Quotient of Multivariate Polynomial Ring in x, y
over Rational Field by the ideal (x^2 + y^2 + 1)

Check ``ideal_class=`` keyword argument when input is empty::

sage: from sage.rings.ideal import Ideal_pid
Expand Down
Loading