@@ -1123,7 +1123,7 @@ def set_bad(i):
11231123 for _ in range (2 ):
11241124 A = Q (flint .fmpz_mat .randtest (30 , 30 , 10 ))
11251125 if A .det () == 0 :
1126- continue
1126+ continue # pragma: no cover
11271127 B = Q (flint .fmpz_mat .randtest (30 , 1 , 10 ))
11281128 X = A .solve (B )
11291129 assert A * X == B
@@ -1548,6 +1548,8 @@ def test_nmod_mat():
15481548 assert raises (lambda : M ([1 ], 5 ), TypeError )
15491549 assert raises (lambda : M ([[1 ],[2 ,3 ]], 5 ), ValueError )
15501550 assert raises (lambda : M ([[1 ],[2 ]], 0 ), ValueError )
1551+ assert raises (lambda : M ([[1 , 2 ], [3 , 4.0 ]], 5 ), TypeError )
1552+ assert raises (lambda : M (2 , 2 , [1 , 2 , 3 , 4.0 ], 5 ), TypeError )
15511553 assert raises (lambda : M (None ), TypeError )
15521554 assert raises (lambda : M (None ,17 ), TypeError )
15531555 assert M (2 ,3 ,17 ) == M (2 ,3 ,[0 ,0 ,0 ,0 ,0 ,0 ],17 )
@@ -1629,29 +1631,36 @@ def test_nmod_series():
16291631
16301632def test_nmod_contexts ():
16311633 # XXX: Generalise this test to cover fmpz_mod, fq_default, etc.
1632- C = flint .nmod_ctx
1634+ CS = flint .nmod_ctx
16331635 CP = flint .nmod_poly_ctx
1634- G = flint .nmod
1636+ CM = flint .nmod_mat_ctx
1637+ S = flint .nmod
16351638 P = flint .nmod_poly
1639+ M = flint .nmod_mat
16361640
1637- for c , name in [(C , 'nmod' ), (CP , 'nmod_poly' )]:
1641+ for c , name in [(CS , 'nmod' ), (CP , 'nmod_poly' ), ( CM , 'nmod_mat ' )]:
16381642 ctx = c .new (17 )
16391643 assert ctx .modulus () == 17
16401644 assert str (ctx ) == f"Context for { name } with modulus: 17"
16411645 assert repr (ctx ) == f"{ name } _ctx(17)"
16421646 assert raises (lambda : c (3 ), TypeError )
16431647 assert raises (lambda : ctx .new (3.0 ), TypeError )
16441648
1645- ctx = C .new (17 )
1646- assert ctx (3 ) == G (3 ,17 ) == G (3 , ctx )
1649+ ctx = CS .new (17 )
1650+ assert ctx (3 ) == S (3 ,17 ) == S (3 , ctx )
16471651 assert raises (lambda : ctx (3.0 ), TypeError )
1648- assert raises (lambda : G (3 , []), TypeError )
1652+ assert raises (lambda : S (3 , []), TypeError )
16491653
16501654 ctx_poly = CP .new (17 )
16511655 assert ctx_poly ([1 ,2 ,3 ]) == P ([1 ,2 ,3 ],17 ) == P ([1 ,2 ,3 ], ctx_poly )
16521656 assert raises (lambda : ctx_poly ([1 ,2.0 ,3 ]), TypeError )
16531657 assert raises (lambda : P ([1 ,2 ,3 ], []), TypeError )
16541658
1659+ ctx_mat = CM .new (17 )
1660+ assert ctx_mat ([[1 ,2 ],[3 ,4 ]]) == M ([[1 ,2 ],[3 ,4 ]],17 ) == M ([[1 ,2 ],[3 ,4 ]], ctx_mat )
1661+ assert raises (lambda : ctx_mat ([[1 ,2.0 ],[3 ,4 ]]), TypeError )
1662+ assert raises (lambda : M ([[1 ,2 ],[3 ,4 ]], []), TypeError )
1663+
16551664
16561665def test_arb ():
16571666 A = flint .arb
@@ -2596,6 +2605,7 @@ def FQ_DEFAULT(n, k):
25962605 NMOD (9 ),
25972606 NMOD (16 ),
25982607 FMPZ_MOD (164 ),
2608+ FMPZ_MOD (9 ),
25992609 FMPZ_MOD (2 ** 127 ),
26002610 FMPZ_MOD (2 ** 255 ),
26012611 ]
@@ -2795,7 +2805,7 @@ def setbad(obj, i, val):
27952805 assert P ([1 , 1 ]) % 2 == P ([1 , 1 ])
27962806 assert P ([2 , 2 ]) / 2 == P ([1 , 1 ])
27972807 assert raises (lambda : P ([1 , 2 ]) / 2 , DomainError )
2798- else :
2808+ elif characteristic . gcd ( 2 ) != 1 or type ( P ( 1 )) is flint . nmod_poly :
27992809 # Z/nZ for n not prime
28002810 assert raises (lambda : P ([1 , 1 ]) // 2 , DomainError )
28012811 assert raises (lambda : P ([1 , 1 ]) % 2 , DomainError )
@@ -2898,7 +2908,7 @@ def setbad(obj, i, val):
28982908 if type (x ) is flint .fmpz_mod_poly :
28992909 assert (1 + x ).inverse_series_trunc (4 ) == 1 - x + x ** 2 - x ** 3
29002910 if characteristic .gcd (3 ) != 1 :
2901- assert ( 3 + x ).inverse_series_trunc (4 ) == 1 - x + x ** 2 - x ** 3
2911+ assert raises ( lambda : ( 3 + x ).inverse_series_trunc (4 ), DomainError )
29022912 else :
29032913 assert (3 + x ).inverse_series_trunc (4 )\
29042914 == S (1 )/ 3 - S (1 )/ 9 * x + S (1 )/ 27 * x ** 2 - S (1 )/ 81 * x ** 3
0 commit comments