astropy/astropy — pull request #3024 by embray (2014-10-10 18:33:58+00:00)
Title: Change Model.inverse to a property instead of a method

This implements a feature suggested by @nden, which will useful especially in defining the inverse of WCS transformations where possible.

The `Model` class has an `inverse()` method that can be overridden by subclasses. Currently it returns a new `Model` instance that computes the inverse of the model it was called on. Currently this is only defined on a few models that have a simple analytic inverse--other models where it is not defined raise `NotImplementedError`.

However, sometimes an inverse transformation may be available--either that was computed by some other means or that was determined experimentally--and it would be useful to attach that to the model to which it is the inverse, even if that model doesn't have a default inverse defined.

To that end it made sense to make `Model.inverse` into a property, where setting `Model.inverse` would override the default if it exists, or provide an inverse where none existed previously at all. (Although there's probably not much reason for it, this also allows restoring the old default by setting `Model.inverse = None`.

Making `Model.inverse` a property also enables alluring syntax like:

```python
>>> r = Rotation2D(90)
>>> r.inverse(*r(0, 1))
(0.0, 1.0)
```

Previously this looked like `r.inverse()(*r(0, 1))`.

One downside to this change is that it's hard to do without breaking backward incompatibility. I *may* be able to devise some kind of proxy that allows it to be used in both ways depending on context. But probably better here to invoke the declared instability of the modeling package's API and just make the change for 1.0 (I *do* hope to be able to remove that warning for 1.0). In this particular case I don't think the inverse feature is widely used yet either.