There may not be a guarantee that c1 and c2 are in the dict and you could wrap the argval calc as

```
if all(coeff_dict.get(i, 0) for i in (c1, c2)) and all(isinstance(i, Rational) for i in coeff_dict.values()):
   ...
```