Minor point:

```
if type(warning) not in (AstropyWarning, AstropyUserWarning)
```

should be faster.