Skip to content

Commit

Permalink
src/sage/modules/vector_space_morphism.py: Remove use of is_VectorSpace
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed May 12, 2024
1 parent c870087 commit 3a59b13
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/sage/modules/vector_space_morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ def linear_transformation(arg0, arg1=None, arg2=None, side='left'):
from sage.categories.homset import Hom
from sage.matrix.constructor import matrix
from sage.modules.free_module import VectorSpace
from sage.modules.module import is_VectorSpace
from sage.modules.module import Module
try:
from sage.modules.vector_callable_symbolic_dense import (
Vector_callable_symbolic_dense,
Expand All @@ -706,8 +706,6 @@ def linear_transformation(arg0, arg1=None, arg2=None, side='left'):

if side not in ['left', 'right']:
raise ValueError("side must be 'left' or 'right', not {}".format(side))
if not (is_Matrix(arg0) or is_VectorSpace(arg0)):
raise TypeError('first argument must be a matrix or a vector space, not {}'.format(arg0))
if is_Matrix(arg0):
R = arg0.base_ring()
if not R.is_field():
Expand All @@ -722,14 +720,15 @@ def linear_transformation(arg0, arg1=None, arg2=None, side='left'):
arg2 = arg0
arg0 = VectorSpace(R, arg2.nrows())
arg1 = VectorSpace(R, arg2.ncols())
elif is_VectorSpace(arg0):
if not is_VectorSpace(arg1):
elif isinstance(arg0, Module) and arg0.base_ring().is_field():
if not (isinstance(arg1, Module) and arg1.base_ring().is_field()):
msg = 'if first argument is a vector space, then second argument must be a vector space, not {0}'
raise TypeError(msg.format(arg1))
if arg0.base_ring() != arg1.base_ring():
msg = 'vector spaces must have the same field of scalars, not {0} and {1}'
raise TypeError(msg.format(arg0.base_ring(), arg1.base_ring()))

else:
raise TypeError('first argument must be a matrix or a vector space, not {}'.format(arg0))
# Now arg0 = domain D, arg1 = codomain C, and
# both are vector spaces with common field of scalars
# use these to make a VectorSpaceHomSpace
Expand Down

0 comments on commit 3a59b13

Please sign in to comment.