the lines below belong up here (indented)

```
    terms[s] += c
    if terms[s] is S.NaN: ...
```

We already know that c alone is not NaN so we gain the efficiency by only checking when we might create a new one: during addition.