@@ -21,6 +21,7 @@ from cysignals.signals cimport sig_check
21
21
MatrixSpace = None
22
22
23
23
from sage.rings.integer_ring import ZZ
24
+ from sage.rings.integer cimport Integer
24
25
from sage.structure.coerce cimport (coercion_model,
25
26
is_numpy_type, py_scalar_parent)
26
27
from sage.structure.element cimport Element, RingElement, Vector
@@ -925,9 +926,10 @@ cdef class MatrixArgs:
925
926
926
927
# Non-zero scalar matrices must be square
927
928
if self .typ == MA_ENTRIES_SCALAR:
928
- if self .nrows ! = self .ncols :
929
- if self .entries :
929
+ if self .entries :
930
+ if self .nrows ! = self .ncols :
930
931
raise TypeError (" nonzero scalar matrix must be square" )
932
+ else :
931
933
self .typ = MA_ENTRIES_ZERO
932
934
933
935
if self .sparse == - 1 :
@@ -1219,12 +1221,14 @@ cdef class MatrixArgs:
1219
1221
# hurt to do these first.
1220
1222
if self .entries is None :
1221
1223
return MA_ENTRIES_ZERO
1224
+ if isinstance (self .entries, (int , float , complex , Integer)):
1225
+ if self .entries:
1226
+ return MA_ENTRIES_SCALAR
1227
+ return MA_ENTRIES_ZERO
1222
1228
if isinstance (self .entries, (list , tuple )):
1223
1229
return self .sequence_type()
1224
1230
if isinstance (self .entries, dict ):
1225
1231
return MA_ENTRIES_MAPPING
1226
- if isinstance (self .entries, (int , float , complex )):
1227
- return MA_ENTRIES_SCALAR
1228
1232
1229
1233
# Note: some objects are callable, iterable and act like a
1230
1234
# scalar, e.g. polynomials. So the order of these checks
0 commit comments