Skip to content

Commit 4b5f2a5

Browse files
committed
add another type check following reviewer comments
1 parent 6663315 commit 4b5f2a5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/sage/modules/free_module_element.pyx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4166,14 +4166,22 @@ cdef class FreeModuleElement(Vector): # abstract base class
41664166
sage: v.concatenate(w).parent()
41674167
Ambient free module of rank 5 over the principal ideal domain Integer Ring
41684168

4169-
The method fails when the vectors aren't defined over the same ring::
4169+
The method fails when the inputs aren't both vectors, or the vectors
4170+
aren't defined over the same ring::
41704171

4172+
sage: w2 = polygen(QQ)^4 + 5
4173+
sage: v.concatenate(w2)
4174+
Traceback (most recent call last):
4175+
...
4176+
TypeError: can only concatenate two vectors
41714177
sage: w2 = vector(QQ, [4, 5])
41724178
sage: v.concatenate(w2)
41734179
Traceback (most recent call last):
41744180
...
41754181
ValueError: can only concatenate vectors over the same base ring
41764182
"""
4183+
if not isinstance(other, FreeModuleElement):
4184+
raise TypeError('can only concatenate two vectors')
41774185
R = self.parent().base_ring()
41784186
if other.parent().base_ring() != R:
41794187
raise ValueError('can only concatenate vectors over the same base ring')

0 commit comments

Comments
 (0)