numpy handles nans in argmin and argmax differently, so I need to use this wrapper to implement the differences.