Not a big fan of that cast here. Maybe use `asarray`, and then further down simply don't do the division in-place (the file imports `division` from `__future__`)?