For testing purposes, it is better to first define _block_diag independently of the version of scipy, and then assign it to block_diag. That way you can test the version for old scipy even on recent scipy.