@@ -27,7 +27,7 @@ def deviations(ip):
27
27
28
28
Returns
29
29
-------
30
- numpy array
30
+ deviations : numpy.ndarray
31
31
The deviation per triangle.
32
32
"""
33
33
values = ip .values / (ip .values .ptp (axis = 0 ).max () or 1 )
@@ -65,7 +65,7 @@ def areas(ip):
65
65
66
66
Returns
67
67
-------
68
- numpy array
68
+ areas : numpy.ndarray
69
69
The area per triangle in ``ip.tri``.
70
70
"""
71
71
p = ip .tri .points [ip .tri .vertices ]
@@ -79,6 +79,15 @@ def uniform_loss(ip):
79
79
80
80
Works with `~adaptive.Learner2D` only.
81
81
82
+ Parameters
83
+ ----------
84
+ ip : `scipy.interpolate.LinearNDInterpolator` instance
85
+
86
+ Returns
87
+ -------
88
+ losses : numpy.ndarray
89
+ Loss per triangle in ``ip.tri``.
90
+
82
91
Examples
83
92
--------
84
93
>>> from adaptive.learner.learner2D import uniform_loss
@@ -103,6 +112,10 @@ def resolution_loss_function(min_distance=0, max_distance=1):
103
112
The arguments `min_distance` and `max_distance` should be in between 0 and 1
104
113
because the total area is normalized to 1.
105
114
115
+ Returns
116
+ -------
117
+ loss_function : callable
118
+
106
119
Examples
107
120
--------
108
121
>>> def f(xy):
@@ -133,12 +146,21 @@ def resolution_loss(ip):
133
146
134
147
135
148
def minimize_triangle_surface_loss (ip ):
136
- """Loss function that is similar to the default loss function in the
149
+ """Loss function that is similar to the distance loss function in the
137
150
`~adaptive.Learner1D`. The loss is the area spanned by the 3D
138
151
vectors of the vertices.
139
152
140
153
Works with `~adaptive.Learner2D` only.
141
154
155
+ Parameters
156
+ ----------
157
+ ip : `scipy.interpolate.LinearNDInterpolator` instance
158
+
159
+ Returns
160
+ -------
161
+ losses : numpy.ndarray
162
+ Loss per triangle in ``ip.tri``.
163
+
142
164
Examples
143
165
--------
144
166
>>> from adaptive.learner.learner2D import minimize_triangle_surface_loss
@@ -170,6 +192,19 @@ def _get_vectors(points):
170
192
171
193
172
194
def default_loss (ip ):
195
+ """Loss function that combines
196
+
197
+ Works with `~adaptive.Learner2D` only.
198
+
199
+ Parameters
200
+ ----------
201
+ ip : `scipy.interpolate.LinearNDInterpolator` instance
202
+
203
+ Returns
204
+ -------
205
+ losses : numpy.ndarray
206
+ Loss per triangle in ``ip.tri``.
207
+ """
173
208
dev = np .sum (deviations (ip ), axis = 0 )
174
209
A = areas (ip )
175
210
losses = dev * np .sqrt (A ) + 0.3 * A
@@ -425,6 +460,12 @@ def interpolator(self, *, scaled=False):
425
460
Returns
426
461
-------
427
462
interpolate : `scipy.interpolate.LinearNDInterpolator`
463
+
464
+ Examples
465
+ --------
466
+ >>> xs, ys = [np.linspace(*b, n=100) for b in learner.bounds]
467
+ >>> ip = learner.interpolator()
468
+ >>> zs = ip(xs[:, None], ys[None, :])
428
469
"""
429
470
if scaled :
430
471
if self ._ip is None :
0 commit comments