Two remarks on this function (which is cool!):

* It should be in utils.extmath

* The routing between the 2 approaches should be performed at module-loading time. In other words, you should implement 2 functions, and at module loading time assign one to 'inv_triangular', as it is currently done for np.unique in utils.fixes.