fyi specifying dtypes in divide is not supported by older numpy versions, so I rewrote that.