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

avoid using isinstance IntegralDomain in modules #38978

Open
wants to merge 1 commit 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
5 changes: 2 additions & 3 deletions src/sage/modules/free_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
#
# The full text of the GPL is available at:
#
# http://www.gnu.org/licenses/
# https://www.gnu.org/licenses/
###########################################################################

import itertools
Expand All @@ -185,7 +185,6 @@
import sage.rings.integer
import sage.rings.integer_ring
import sage.rings.rational_field
from sage.rings.ring import IntegralDomain
from sage.categories.commutative_rings import CommutativeRings
from sage.categories.fields import Fields
from sage.categories.infinite_enumerated_sets import InfiniteEnumeratedSets
Expand Down Expand Up @@ -296,7 +295,7 @@ def create_object(self, version, key):
and base_ring.is_maximal() and base_ring.class_number() == 1):
return FreeModule_ambient_pid(base_ring, rank, sparse=sparse)

if isinstance(base_ring, IntegralDomain) or base_ring in IntegralDomains():
if base_ring in IntegralDomains():
return FreeModule_ambient_domain(base_ring, rank, sparse=sparse)

return FreeModule_ambient(base_ring, rank, sparse=sparse)
Expand Down
5 changes: 3 additions & 2 deletions src/sage/modules/free_quadratic_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@

from sage.categories.commutative_rings import CommutativeRings
from sage.categories.principal_ideal_domains import PrincipalIdealDomains
from sage.categories.integral_domains import IntegralDomains
from sage.modules import free_module
from sage.rings.ring import Field, IntegralDomain
from sage.rings.ring import Field
import sage.matrix.matrix_space
import sage.misc.latex as latex

Expand Down Expand Up @@ -175,7 +176,7 @@ def FreeQuadraticModule(base_ring, rank, inner_product_matrix,
M = FreeQuadraticModule_ambient_pid(
base_ring, rank, sparse=sparse, inner_product_matrix=inner_product_matrix)

elif isinstance(base_ring, IntegralDomain) or base_ring.is_integral_domain():
elif base_ring in IntegralDomains():
M = FreeQuadraticModule_ambient_domain(
base_ring, rank, sparse=sparse, inner_product_matrix=inner_product_matrix)
else:
Expand Down
Loading