Closed jurasofish closed 4 years ago
Hello Michael, We raise a ModuleNotFoundError error when someone tries to use numpy-related features and numpy is not available, not the base Exception. The idea is to make numpy optional. Am I missing something?
I made PR #106 to show what I mean - it's generally desirable to catch the most specific exception possible. Especially in the case of the ndarray.py file, where any issue creating that class would have been caught and treated as though numpy wasn't available. By catching only ImportError we ensure that only import issues are caught. The logging means that if the user expects numpy to import properly but there's an issue importing numpy the user can look at the debug level logs to help them figure out why it's not importing.
Thanks!
In 5b9aa03f0b4f65822d578d7c7ba0f237350059f2 importing numpy excepts the base Exception class to indicate that numpy isn't available. This is too broad an exception and will catch exceptions that it shouldn't. Catching ImportError is what the code really intends to do.