Same goes for `transform` and `transform_inverse`. I think that you can substantially reduce the amount of code here, by capturing the underlying patterns in fewer lines of code that use logic to switch between these different options. Unless, I am missing something.