Skip to content

Commit

Permalink
Merge pull request #8736 from astrofrog/remove-compound-class
Browse files Browse the repository at this point in the history
Remove deprecated use of class composition in modeling docs
  • Loading branch information
pllim committed May 20, 2019
2 parents aa90993 + 86364a4 commit e0e433f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion astropy/modeling/core.py
Expand Up @@ -72,7 +72,7 @@ def _opfunc(left, right):
# Deprecation is for https://github.com/astropy/astropy/issues/8234
if not (isinstance(left, Model) and isinstance(right, Model)):
warnings.warn(
'Composition of model classes will be removed in 4.0'
'Composition of model classes will be removed in 4.0 '
'(but composition of model instances is not affected)',
AstropyDeprecationWarning)

Expand Down
12 changes: 3 additions & 9 deletions docs/modeling/compound-models.rst
Expand Up @@ -429,17 +429,14 @@ example, to create the following compound model:
import matplotlib.pyplot as plt
from astropy.modeling.models import RedshiftScaleFactor, Gaussian1D

class RedshiftedGaussian(RedshiftScaleFactor | Gaussian1D(1, 0.75, 0.1)):
"""Evaluates a Gaussian with optional redshift applied to the input."""

x = np.linspace(0, 1.2, 100)
g0 = RedshiftedGaussian(z_0=0)
g0 = RedshiftScaleFactor(0) | Gaussian1D(1, 0.75, 0.1)

plt.figure(figsize=(8, 5))
plt.plot(x, g0(x), 'g--', label='$z=0$')

for z in (0.2, 0.4, 0.6):
g = RedshiftedGaussian(z_0=z)
g = RedshiftScaleFactor(z) | Gaussian1D(1, 0.75, 0.1)
plt.plot(x, g(x), color=plt.cm.OrRd(z),
label='$z={0}$'.format(z))

Expand Down Expand Up @@ -506,15 +503,12 @@ example:
import matplotlib.pyplot as plt
from astropy.modeling.models import Rotation2D, Gaussian2D

class RotatedGaussian(Rotation2D | Gaussian2D(1, 0, 0, 0.1, 0.3)):
"""A Gaussian2D composed with a coordinate rotation."""

x, y = np.mgrid[-1:1:0.01, -1:1:0.01]

plt.figure(figsize=(8, 2.5))

for idx, theta in enumerate((0, 45, 90)):
g = RotatedGaussian(theta)
g = Rotation2D(theta) | Gaussian2D(1, 0, 0, 0.1, 0.3)
plt.subplot(1, 3, idx + 1)
plt.imshow(g(x, y), origin='lower')
plt.xticks([])
Expand Down

0 comments on commit e0e433f

Please sign in to comment.