@@ -3279,7 +3279,10 @@ def factor(p):
32793279
32803280 for P , S , [x , y ], is_field , characteristic_zero in _all_polys_mpolys ():
32813281
3282+ assert factor (0 * x ) == (S (0 ), [])
3283+ assert factor (0 * x + 1 ) == (S (1 ), [])
32823284 assert factor (x ) == (S (1 ), [(x , 1 )])
3285+ assert factor (- x ) == (S (- 1 ), [(x , 1 )])
32833286 assert factor (x ** 2 ) == (S (1 ), [(x , 2 )])
32843287 assert factor (x * (x + 1 )) == (S (1 ), [(x , 1 ), (x + 1 , 1 )])
32853288 assert factor (2 * (x + 1 )) == (S (2 ), [(x + 1 , 1 )])
@@ -3293,10 +3296,8 @@ def factor(p):
32933296
32943297 if is_field :
32953298 if characteristic_zero :
3296- # primitive factors over Z for Z and Q.
32973299 assert factor ((2 * x + 1 )/ 7 ) == (S (1 )/ 7 , [(2 * x + 1 , 1 )])
32983300 else :
3299- # monic factors over Z/pZ and GF(p^d)
33003301 assert factor ((2 * x + 1 )/ 7 ) == (S (2 )/ 7 , [(x + S (1 )/ 2 , 1 )])
33013302
33023303 if y is not None :
@@ -3305,12 +3306,16 @@ def factor(p):
33053306 assert factor (x * y ) == (S (1 ), [(x , 1 ), (y , 1 )])
33063307
33073308 if characteristic_zero :
3308- # primitive factors over Z for Z and Q.
33093309 assert factor (2 * x + y ) == (S (1 ), [(2 * x + y , 1 )])
33103310 else :
3311- # monic factors over Z/pZ and GF(p^d)
33123311 assert factor (2 * x + y ) == (S (1 )/ 2 , [(x + y / 2 , 1 )])
33133312
3313+ if is_field :
3314+ if characteristic_zero :
3315+ assert factor ((2 * x + y )/ 7 ) == (S (1 )/ 7 , [(2 * x + y , 1 )])
3316+ else :
3317+ assert factor ((2 * x + y )/ 7 ) == (S (2 )/ 7 , [(x + y / 2 , 1 )])
3318+
33143319
33153320def _all_matrices ():
33163321 """Return a list of matrix types and scalar types."""
0 commit comments