fixed some errors reported by pyflakes
raise exception instead of converting sparse arrays to dense