68
68
import weakref
69
69
70
70
from sage .categories .commutative_rings import CommutativeRings
71
+ from sage .categories .fields import Fields
71
72
from sage .categories .principal_ideal_domains import PrincipalIdealDomains
72
73
from sage .categories .integral_domains import IntegralDomains
73
74
from sage .modules import free_module
74
- from sage .rings .ring import Field
75
75
import sage .matrix .matrix_space
76
76
import sage .misc .latex as latex
77
77
@@ -168,7 +168,7 @@ def FreeQuadraticModule(base_ring, rank, inner_product_matrix,
168
168
# elif not sparse and isinstance(base_ring,sage.rings.complex_double.ComplexDoubleField_class):
169
169
# M = ComplexDoubleQuadraticSpace_class(rank, inner_product_matrix=inner_product_matrix, sparse=False)
170
170
171
- elif base_ring . is_field ():
171
+ if base_ring in Fields ():
172
172
M = FreeQuadraticModule_ambient_field (
173
173
base_ring , rank , sparse = sparse , inner_product_matrix = inner_product_matrix )
174
174
@@ -213,7 +213,7 @@ def QuadraticSpace(K, dimension, inner_product_matrix, sparse=False):
213
213
...
214
214
TypeError: argument K (= Integer Ring) must be a field
215
215
"""
216
- if not K . is_field ():
216
+ if K not in Fields ():
217
217
raise TypeError (f"argument K (= { K } ) must be a field" )
218
218
if sparse not in (True , False ):
219
219
raise TypeError ("Argument sparse (= %s) must be a boolean." % sparse )
@@ -307,7 +307,8 @@ class FreeQuadraticModule_generic(free_module.FreeModule_generic):
307
307
sage: M1 == M2
308
308
False
309
309
"""
310
- def __init__ (self , base_ring , rank , degree , inner_product_matrix , sparse = False ):
310
+ def __init__ (self , base_ring , rank , degree ,
311
+ inner_product_matrix , sparse = False ) -> None :
311
312
"""
312
313
Create the free module of given rank over the given ``base_ring``.
313
314
@@ -589,7 +590,8 @@ class FreeQuadraticModule_generic_pid(free_module.FreeModule_generic_pid,
589
590
"""
590
591
Class of all free modules over a PID.
591
592
"""
592
- def __init__ (self , base_ring , rank , degree , inner_product_matrix , sparse = False ):
593
+ def __init__ (self , base_ring , rank , degree ,
594
+ inner_product_matrix , sparse = False ) -> None :
593
595
"""
594
596
Create a free module over a PID.
595
597
@@ -696,7 +698,8 @@ class FreeQuadraticModule_generic_field(free_module.FreeModule_generic_field,
696
698
"""
697
699
Base class for all free modules over fields.
698
700
"""
699
- def __init__ (self , base_field , dimension , degree , inner_product_matrix , sparse = False ):
701
+ def __init__ (self , base_field , dimension , degree ,
702
+ inner_product_matrix , sparse = False ) -> None :
700
703
"""
701
704
Create a vector space over a field.
702
705
@@ -718,10 +721,11 @@ def __init__(self, base_field, dimension, degree, inner_product_matrix, sparse=F
718
721
[0 0 0 0 0 1 0]
719
722
[0 0 0 0 0 0 1]
720
723
"""
721
- if not isinstance ( base_field , Field ):
722
- raise TypeError ("the base_field (=%s ) must be a field" % base_field )
724
+ if base_field not in Fields ( ):
725
+ raise TypeError (f "the base_field (={ base_field } ) must be a field" )
723
726
free_module .FreeModule_generic_field .__init__ (
724
- self , base_field = base_field , dimension = dimension , degree = degree , sparse = sparse )
727
+ self , base_field = base_field , dimension = dimension ,
728
+ degree = degree , sparse = sparse )
725
729
self ._inner_product_matrix = inner_product_matrix
726
730
727
731
def span (self , gens , check = True , already_echelonized = False ):
@@ -820,7 +824,8 @@ class FreeQuadraticModule_ambient(free_module.FreeModule_ambient,
820
824
"""
821
825
Ambient free module over a commutative ring.
822
826
"""
823
- def __init__ (self , base_ring , rank , inner_product_matrix , sparse = False ):
827
+ def __init__ (self , base_ring , rank ,
828
+ inner_product_matrix , sparse = False ) -> None :
824
829
"""
825
830
The free module of given rank over the given ``base_ring``.
826
831
@@ -838,7 +843,7 @@ def __init__(self, base_ring, rank, inner_product_matrix, sparse=False):
838
843
free_module .FreeModule_ambient .__init__ (self , base_ring = base_ring , rank = rank , sparse = sparse )
839
844
self ._inner_product_matrix = inner_product_matrix
840
845
841
- def _repr_ (self ):
846
+ def _repr_ (self ) -> str :
842
847
"""
843
848
The printing representation of ``self``.
844
849
@@ -872,7 +877,7 @@ def _repr_(self):
872
877
return "Ambient free quadratic module of rank %s over %s\n " % (self .rank (), self .base_ring ()) + \
873
878
"Inner product matrix:\n %s" % self .inner_product_matrix ()
874
879
875
- def _latex_ (self ):
880
+ def _latex_ (self ) -> str :
876
881
r"""
877
882
Return a latex representation of this ambient free quadratic module.
878
883
@@ -944,7 +949,8 @@ class FreeQuadraticModule_ambient_domain(free_module.FreeModule_ambient_domain,
944
949
"""
945
950
Ambient free quadratic module over an integral domain.
946
951
"""
947
- def __init__ (self , base_ring , rank , inner_product_matrix , sparse = False ):
952
+ def __init__ (self , base_ring , rank ,
953
+ inner_product_matrix , sparse = False ) -> None :
948
954
"""
949
955
EXAMPLES::
950
956
@@ -955,7 +961,7 @@ def __init__(self, base_ring, rank, inner_product_matrix, sparse=False):
955
961
free_module .FreeModule_ambient .__init__ (self , base_ring = base_ring , rank = rank , sparse = sparse )
956
962
self ._inner_product_matrix = inner_product_matrix
957
963
958
- def _repr_ (self ):
964
+ def _repr_ (self ) -> str :
959
965
"""
960
966
The printing representation of ``self``.
961
967
@@ -1035,7 +1041,8 @@ class FreeQuadraticModule_ambient_pid(free_module.FreeModule_ambient_pid,
1035
1041
"""
1036
1042
Ambient free quadratic module over a principal ideal domain.
1037
1043
"""
1038
- def __init__ (self , base_ring , rank , inner_product_matrix , sparse = False ):
1044
+ def __init__ (self , base_ring , rank ,
1045
+ inner_product_matrix , sparse = False ) -> None :
1039
1046
"""
1040
1047
Create the ambient free module of given rank over the given
1041
1048
principal ideal domain.
@@ -1064,7 +1071,7 @@ def __init__(self, base_ring, rank, inner_product_matrix, sparse=False):
1064
1071
free_module .FreeModule_ambient_pid .__init__ (self , base_ring = base_ring , rank = rank , sparse = sparse )
1065
1072
self ._inner_product_matrix = inner_product_matrix
1066
1073
1067
- def _repr_ (self ):
1074
+ def _repr_ (self ) -> str :
1068
1075
"""
1069
1076
The printing representation of ``self``.
1070
1077
@@ -1120,7 +1127,8 @@ class FreeQuadraticModule_ambient_field(free_module.FreeModule_ambient_field,
1120
1127
FreeQuadraticModule_generic_field ,
1121
1128
FreeQuadraticModule_ambient_pid ):
1122
1129
1123
- def __init__ (self , base_field , dimension , inner_product_matrix , sparse = False ):
1130
+ def __init__ (self , base_field , dimension ,
1131
+ inner_product_matrix , sparse = False ) -> None :
1124
1132
"""
1125
1133
Create the ambient vector space of given dimension over the given field.
1126
1134
@@ -1158,7 +1166,7 @@ def __init__(self, base_field, dimension, inner_product_matrix, sparse=False):
1158
1166
self , base_field = base_field , dimension = dimension , sparse = sparse )
1159
1167
self ._inner_product_matrix = inner_product_matrix
1160
1168
1161
- def _repr_ (self ):
1169
+ def _repr_ (self ) -> str :
1162
1170
"""
1163
1171
The printing representation of ``self``.
1164
1172
@@ -1239,7 +1247,7 @@ class FreeQuadraticModule_submodule_with_basis_pid(free_module.FreeModule_submod
1239
1247
"""
1240
1248
def __init__ (self , ambient , basis , inner_product_matrix ,
1241
1249
check = True , echelonize = False , echelonized_basis = None ,
1242
- already_echelonized = False ):
1250
+ already_echelonized = False ) -> None :
1243
1251
"""
1244
1252
Create a free module with basis over a PID.
1245
1253
@@ -1282,7 +1290,7 @@ def __init__(self, ambient, basis, inner_product_matrix,
1282
1290
echelonize = echelonize , echelonized_basis = echelonized_basis , already_echelonized = already_echelonized )
1283
1291
self ._inner_product_matrix = inner_product_matrix
1284
1292
1285
- def _repr_ (self ):
1293
+ def _repr_ (self ) -> str :
1286
1294
"""
1287
1295
The printing representation of ``self``.
1288
1296
@@ -1326,7 +1334,7 @@ def _repr_(self):
1326
1334
"Inner product matrix:\n %r" % self .inner_product_matrix ()
1327
1335
return s
1328
1336
1329
- def _latex_ (self ):
1337
+ def _latex_ (self ) -> str :
1330
1338
r"""
1331
1339
Return latex representation of this free module.
1332
1340
@@ -1410,7 +1418,9 @@ class FreeQuadraticModule_submodule_pid(free_module.FreeModule_submodule_pid,
1410
1418
sage: loads(v.dumps()) == v
1411
1419
True
1412
1420
"""
1413
- def __init__ (self , ambient , gens , inner_product_matrix , check = True , already_echelonized = False ):
1421
+ def __init__ (self , ambient , gens ,
1422
+ inner_product_matrix , check = True ,
1423
+ already_echelonized = False ) -> None :
1414
1424
"""
1415
1425
Create an embedded free module over a PID.
1416
1426
@@ -1428,7 +1438,7 @@ def __init__(self, ambient, gens, inner_product_matrix, check=True, already_eche
1428
1438
self , ambient = ambient , gens = gens , check = check , already_echelonized = already_echelonized )
1429
1439
self ._inner_product_matrix = inner_product_matrix
1430
1440
1431
- def _repr_ (self ):
1441
+ def _repr_ (self ) -> str :
1432
1442
"""
1433
1443
The printing representation of ``self``.
1434
1444
@@ -1507,7 +1517,8 @@ class FreeQuadraticModule_submodule_with_basis_field(free_module.FreeModule_subm
1507
1517
True
1508
1518
"""
1509
1519
def __init__ (self , ambient , basis , inner_product_matrix ,
1510
- check = True , echelonize = False , echelonized_basis = None , already_echelonized = False ):
1520
+ check = True , echelonize = False , echelonized_basis = None ,
1521
+ already_echelonized = False ) -> None :
1511
1522
"""
1512
1523
Create a vector space with given basis.
1513
1524
@@ -1536,7 +1547,7 @@ def __init__(self, ambient, basis, inner_product_matrix,
1536
1547
echelonize = echelonize , echelonized_basis = echelonized_basis , already_echelonized = already_echelonized )
1537
1548
self ._inner_product_matrix = inner_product_matrix
1538
1549
1539
- def _repr_ (self ):
1550
+ def _repr_ (self ) -> str :
1540
1551
"""
1541
1552
The printing representation of ``self``.
1542
1553
@@ -1627,7 +1638,8 @@ class FreeQuadraticModule_submodule_field(free_module.FreeModule_submodule_field
1627
1638
sage: vector(QQ, W.coordinates(v)) * W.basis_matrix()
1628
1639
(1, 5, 9)
1629
1640
"""
1630
- def __init__ (self , ambient , gens , inner_product_matrix , check = True , already_echelonized = False ):
1641
+ def __init__ (self , ambient , gens , inner_product_matrix , check = True ,
1642
+ already_echelonized = False ) -> None :
1631
1643
"""
1632
1644
Create an embedded vector subspace with echelonized basis.
1633
1645
@@ -1645,7 +1657,7 @@ def __init__(self, ambient, gens, inner_product_matrix, check=True, already_eche
1645
1657
self , ambient = ambient , gens = gens , check = check , already_echelonized = already_echelonized )
1646
1658
self ._inner_product_matrix = inner_product_matrix
1647
1659
1648
- def _repr_ (self ):
1660
+ def _repr_ (self ) -> str :
1649
1661
"""
1650
1662
The default printing representation of ``self``.
1651
1663
0 commit comments