backport to old numpy version.