@@ -3208,7 +3208,10 @@ def factor(p):
32083208
32093209 for P , S , [x , y ], is_field , characteristic_zero in _all_polys_mpolys ():
32103210
3211+ assert factor (0 * x ) == (S (0 ), [])
3212+ assert factor (0 * x + 1 ) == (S (1 ), [])
32113213 assert factor (x ) == (S (1 ), [(x , 1 )])
3214+ assert factor (- x ) == (S (- 1 ), [(x , 1 )])
32123215 assert factor (x ** 2 ) == (S (1 ), [(x , 2 )])
32133216 assert factor (x * (x + 1 )) == (S (1 ), [(x , 1 ), (x + 1 , 1 )])
32143217 assert factor (2 * (x + 1 )) == (S (2 ), [(x + 1 , 1 )])
@@ -3222,10 +3225,8 @@ def factor(p):
32223225
32233226 if is_field :
32243227 if characteristic_zero :
3225- # primitive factors over Z for Z and Q.
32263228 assert factor ((2 * x + 1 )/ 7 ) == (S (1 )/ 7 , [(2 * x + 1 , 1 )])
32273229 else :
3228- # monic factors over Z/pZ and GF(p^d)
32293230 assert factor ((2 * x + 1 )/ 7 ) == (S (2 )/ 7 , [(x + S (1 )/ 2 , 1 )])
32303231
32313232 if y is not None :
@@ -3234,12 +3235,16 @@ def factor(p):
32343235 assert factor (x * y ) == (S (1 ), [(x , 1 ), (y , 1 )])
32353236
32363237 if characteristic_zero :
3237- # primitive factors over Z for Z and Q.
32383238 assert factor (2 * x + y ) == (S (1 ), [(2 * x + y , 1 )])
32393239 else :
3240- # monic factors over Z/pZ and GF(p^d)
32413240 assert factor (2 * x + y ) == (S (1 )/ 2 , [(x + y / 2 , 1 )])
32423241
3242+ if is_field :
3243+ if characteristic_zero :
3244+ assert factor ((2 * x + y )/ 7 ) == (S (1 )/ 7 , [(2 * x + y , 1 )])
3245+ else :
3246+ assert factor ((2 * x + y )/ 7 ) == (S (2 )/ 7 , [(x + y / 2 , 1 )])
3247+
32433248
32443249def _all_matrices ():
32453250 """Return a list of matrix types and scalar types."""
0 commit comments