Skip to content

Commit c851559

Browse files
committed
Misc. fixes to astropy.modeling docs
1 parent e21b1b1 commit c851559

7 files changed

Lines changed: 52 additions & 45 deletions

File tree

‎astropy/modeling/core.py‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -684,11 +684,6 @@ class LabeledInput(dict):
684684
labels : list of strings
685685
names matching each coordinate in data
686686
687-
Returns
688-
-------
689-
data : LabeledData
690-
a dict of input data and their assigned labels
691-
692687
Examples
693688
--------
694689
>>> x,y = np.mgrid[:5, :5]

‎astropy/modeling/fitting.py‎

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
model's parameters attribute. The idea is to make this extensible and allow
88
users to easily add other fitters.
99
10-
Linear fitting is done using Numpy's `~numpy.linalg.lstsq` function.
11-
There are currently two non-linear fitters which use `~scipy.optimize.leastsq` and
12-
`~scipy.optimize.slsqp` functions in scipy.optimize.\
10+
Linear fitting is done using the `numpy.linalg.lstsq` function.
11+
There are currently two non-linear fitters which use `scipy.optimize.leastsq` and
12+
`scipy.optimize.fmin_slsqp` functions from `scipy.optimize`.
1313
"""
1414

1515
from __future__ import (absolute_import, unicode_literals, division,
@@ -163,7 +163,8 @@ class LinearLSQFitter(Fitter):
163163
164164
Parameters
165165
----------
166-
model : an instance of `~astropy.modeling.core.ParametricModel`
166+
model : `~astropy.modeling.core.ParametricModel`
167+
The model.
167168
168169
Raises
169170
------
@@ -349,16 +350,6 @@ class NonLinearLSQFitter(Fitter):
349350
"""
350351
A class performing non-linear least squares fitting using the
351352
Levenberg-Marquardt algorithm implemented in `scipy.optimize.leastsq`.
352-
353-
Parameters
354-
----------
355-
model : a fittable `~astropy.modeling.core.ParametricModel`
356-
model to fit to data
357-
358-
Raises
359-
------
360-
ModelLinearityError
361-
A linear model is passed to a nonlinear fitter
362353
"""
363354

364355
supported_constraints = ['fixed', 'tied', 'bounds']
@@ -377,6 +368,16 @@ def __init__(self):
377368
super(NonLinearLSQFitter, self).__init__()
378369

379370
def errorfunc(self, fps, *args):
371+
"""
372+
Compute the sum of the squared residuals.
373+
374+
Parameters
375+
----------
376+
fps : list
377+
parameters returned by the fitter
378+
args : list
379+
input coordinates
380+
"""
380381
model = args[0]
381382
self._fitter_to_model_params(model, fps)
382383
meas = args[-1]
@@ -443,6 +444,11 @@ def __call__(self, model, x, y, z=None, weights=None,
443444
------
444445
model_copy : `ParametricModel`
445446
a copy of the input model with parameters set by the fitter
447+
448+
Raises
449+
------
450+
ModelLinearityError
451+
A linear model is passed to a nonlinear fitter
446452
"""
447453
if isinstance(model, _CompositeModel):
448454
raise NotImplementedError("Fitting of composite models is not implemented in astropy v.0.3.")
@@ -529,11 +535,6 @@ class SLSQPFitter(Fitter):
529535
parameters, as well as bounded constraints. Uses
530536
`scipy.optimize.fmin_slsqp`.
531537
532-
Raises
533-
------
534-
ModelLinearityError
535-
A linear model is passed to a nonlinear fitter
536-
537538
References
538539
----------
539540
.. [1] http://www.netlib.org/toms/733
@@ -552,7 +553,7 @@ def __init__(self):
552553

553554
def errorfunc(self, fps, *args):
554555
"""
555-
Compute the sum of the squared residuals
556+
Compute the sum of the squared residuals.
556557
557558
Parameters
558559
----------
@@ -601,6 +602,11 @@ def __call__(self, model, x, y, z=None, weights=None, verblevel=0,
601602
------
602603
model_copy : `ParametricModel`
603604
a copy of the input model with parameters set by the fitter
605+
606+
Raises
607+
------
608+
ModelLinearityError
609+
A linear model is passed to a nonlinear fitter
604610
"""
605611
if isinstance(model, _CompositeModel):
606612
raise NotImplementedError("Fitting of composite models is not implemented in astropy v.0.3.")

‎astropy/modeling/functional_models.py‎

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,34 +1206,38 @@ def fit_deriv(x, y, amplitude, x_0, y_0, gamma, alpha):
12061206

12071207

12081208
def custom_model_1d(func, func_fit_deriv=None):
1209-
"""
1210-
Create a one dimensional model from a user defined function. The
1211-
parameters of the model will be inferred from the arguments of
1209+
"""Create a one dimensional model from a user defined function.
1210+
1211+
The parameters of the model will be inferred from the arguments of
12121212
the function.
12131213
1214-
..note ::
1215-
All model parameters have to be defined as keyword arguments
1216-
with default values in the model function.
1214+
All model parameters have to be defined as keyword arguments
1215+
with default values in the model function.
12171216
12181217
If you want to use parameter sets in the model, the parameters should be
12191218
treated as lists or arrays.
12201219
12211220
Parameters
12221221
----------
12231222
func : function
1224-
Function which defines the model. It should take one positional
1223+
Function which defines the model. It should take one positional
12251224
argument (the independent variable in the model), and any number of
1226-
keyword arguments (the parameters). It must return the value
1225+
keyword arguments (the parameters). It must return the value
12271226
of the model (typically as an array, but can also be a scalar for
1228-
scalar inputs). This corresponds to the `ParametricModel.eval` method.
1227+
scalar inputs).
1228+
This corresponds to the ``ParametricModel.eval`` method.
12291229
func_fit_deriv : function, optional
12301230
Function which defines the Jacobian derivative of the model. I.e., the
1231-
derivive with respect to the *parameters* of the model. It should
1231+
derivive with respect to the *parameters* of the model. It should
12321232
have the same argument signature as `func`, but should return a
12331233
sequence where each element of the sequence is the derivative
1234-
with respect to the correseponding argument. This corresponds to the
1235-
`ParametricModel.fit_deriv` method.
1234+
with respect to the correseponding argument.
1235+
This corresponds to the ``ParametricModel.fit_deriv`` method.
12361236
1237+
Returns
1238+
-------
1239+
model : Parametric1DModel
1240+
Model class instance
12371241
12381242
Examples
12391243
--------

‎astropy/modeling/polynomial.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,8 @@ def __init__(self, crpix, a_order, a_coeff, b_order, b_coeff,
12001200

12011201

12021202
class SIP(_SIPModel):
1203+
__doc__ = _SIPModel.__doc__
1204+
12031205
def __init__(self, crpix, a_order, a_coeff, b_order, b_coeff,
12041206
ap_order=None, ap_coeff=None, bp_order=None, bp_coeff=None,
12051207
param_dim=1):
@@ -1209,6 +1211,7 @@ def __init__(self, crpix, a_order, a_coeff, b_order, b_coeff,
12091211
bp_order, bp_coeff, param_dim=1)
12101212

12111213
def inverse(self):
1214+
"""Inverse transform."""
12121215
if (self.ap_order is not None and self.ap_coeff is not None and
12131216
self.bp_order is not None and self.bp_coeff is not None):
12141217
return InverseSIP(self.crpix, self.a_order, self.a_coeff,
@@ -1256,6 +1259,8 @@ def __call__(self, x, y):
12561259

12571260

12581261
class InverseSIP(_SIPModel):
1262+
__doc__ = _SIPModel.__doc__
1263+
12591264
def __init__(self, crpix, a_order, a_coeff, b_order, b_coeff,
12601265
ap_order, ap_coeff, bp_order, bp_coeff,
12611266
param_dim=1):
@@ -1266,6 +1271,7 @@ def __init__(self, crpix, a_order, a_coeff, b_order, b_coeff,
12661271
bp_order, bp_coeff, param_dim=1)
12671272

12681273
def inverse(self):
1274+
"""Inverse transform."""
12691275
if (self.a_order is not None and self.a_coeff is not None and
12701276
self.b_order is not None and self.bp_coeff is not None):
12711277
return SIP(self.crpix, self.a_order, self.a_coeff,

‎astropy/modeling/rotations.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44
Implements spherical rotations, defined in WCS Paper II [1]_
55
6-
RotateNative2Celestial and RotateCelestial2Native follow the convention
6+
`RotateNative2Celestial` and `RotateCelestial2Native` follow the convention
77
in WCS paper II to rotate to/from a native sphere and the celestial sphere.
88
99
The user interface uses angles in degrees but the values are stored internally

‎docs/modeling/fitting.rst‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ instance of `~astropy.modeling.core.ParametricModel` as input and modify
88
`~astropy.modeling.core.ParametricModel.parameters` attribute. The idea is to
99
make this extensible and allow users to easily add other fitters.
1010

11-
Linear fitting is done using Numpy's `~numpy.linalg.lstsq` function. There are
12-
currently two non-linear fitters which use `~scipy.optimize.leastsq` and
13-
`~scipy.optimize.fmin_slsqp`.
14-
1511
The rules for passing input to fitters are:
1612

1713
* Non-linear fitters work only with single data sets.

‎docs/modeling/index.rst‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Models And Fitting (`astropy.modeling`)
77
Introduction
88
============
99

10-
`~astropy.modeling` provides a framework for representing models and
10+
`astropy.modeling` provides a framework for representing models and
1111
performing model evaluation and fitting. It supports 1D and 2D models
1212
and fitting with parameter constraints.
1313

@@ -168,8 +168,8 @@ weighting of datapoints, fixing or linking parameters, and placing lower or
168168
upper limits on parameters. For more information on these, take a look at the
169169
:doc:`fitting` documentation.
170170

171-
Using `modeling`
172-
================
171+
Using `astropy.modeling`
172+
========================
173173

174174
.. toctree::
175175
:maxdepth: 1

0 commit comments

Comments
 (0)