MAINT: Use warnings context manager instead of doing it by hand