@@ -40,11 +40,11 @@ def deviations(ip: LinearNDInterpolator) -> list[np.ndarray]:
40
40
41
41
Parameters
42
42
----------
43
- ip : `scipy.interpolate.LinearNDInterpolator` instance
43
+ ip
44
44
45
45
Returns
46
46
-------
47
- deviations : list
47
+ deviations
48
48
The deviation per triangle.
49
49
"""
50
50
values = ip .values / (ip .values .ptp (axis = 0 ).max () or 1 )
@@ -79,11 +79,11 @@ def areas(ip: LinearNDInterpolator) -> np.ndarray:
79
79
80
80
Parameters
81
81
----------
82
- ip : `scipy.interpolate.LinearNDInterpolator` instance
82
+ ip
83
83
84
84
Returns
85
85
-------
86
- areas : numpy.ndarray
86
+ areas
87
87
The area per triangle in ``ip.tri``.
88
88
"""
89
89
p = ip .tri .points [ip .tri .simplices ]
@@ -99,11 +99,11 @@ def uniform_loss(ip: LinearNDInterpolator) -> np.ndarray:
99
99
100
100
Parameters
101
101
----------
102
- ip : `scipy.interpolate.LinearNDInterpolator` instance
102
+ ip
103
103
104
104
Returns
105
105
-------
106
- losses : numpy.ndarray
106
+ losses
107
107
Loss per triangle in ``ip.tri``.
108
108
109
109
Examples
@@ -136,7 +136,7 @@ def resolution_loss_function(
136
136
137
137
Returns
138
138
-------
139
- loss_function : callable
139
+ loss_function
140
140
141
141
Examples
142
142
--------
@@ -173,11 +173,11 @@ def minimize_triangle_surface_loss(ip: LinearNDInterpolator) -> np.ndarray:
173
173
174
174
Parameters
175
175
----------
176
- ip : `scipy.interpolate.LinearNDInterpolator` instance
176
+ ip
177
177
178
178
Returns
179
179
-------
180
- losses : numpy.ndarray
180
+ losses
181
181
Loss per triangle in ``ip.tri``.
182
182
183
183
Examples
@@ -217,11 +217,11 @@ def default_loss(ip: LinearNDInterpolator) -> np.ndarray:
217
217
218
218
Parameters
219
219
----------
220
- ip : `scipy.interpolate.LinearNDInterpolator` instance
220
+ ip
221
221
222
222
Returns
223
223
-------
224
- losses : numpy.ndarray
224
+ losses
225
225
Loss per triangle in ``ip.tri``.
226
226
"""
227
227
dev = np .sum (deviations (ip ), axis = 0 )
@@ -241,15 +241,15 @@ def choose_point_in_triangle(triangle: np.ndarray, max_badness: int) -> np.ndarr
241
241
242
242
Parameters
243
243
----------
244
- triangle : numpy.ndarray
244
+ triangle
245
245
The coordinates of a triangle with shape (3, 2).
246
- max_badness : int
246
+ max_badness
247
247
The badness at which the point is either chosen on a edge or
248
248
in the middle.
249
249
250
250
Returns
251
251
-------
252
- point : numpy.ndarray
252
+ point
253
253
The x and y coordinate of the suggested new point.
254
254
"""
255
255
a , b , c = triangle
@@ -267,17 +267,17 @@ def choose_point_in_triangle(triangle: np.ndarray, max_badness: int) -> np.ndarr
267
267
return point
268
268
269
269
270
- def triangle_loss (ip ) :
270
+ def triangle_loss (ip : LinearNDInterpolator ) -> list [ float ] :
271
271
r"""Computes the average of the volumes of the simplex combined with each
272
272
neighbouring point.
273
273
274
274
Parameters
275
275
----------
276
- ip : `scipy.interpolate.LinearNDInterpolator` instance
276
+ ip
277
277
278
278
Returns
279
279
-------
280
- triangle_loss : list
280
+ triangle_loss
281
281
The mean volume per triangle.
282
282
283
283
Notes
@@ -311,13 +311,13 @@ class Learner2D(BaseLearner):
311
311
312
312
Parameters
313
313
----------
314
- function : callable
314
+ function
315
315
The function to learn. Must take a tuple of two real
316
316
parameters and return a real number.
317
- bounds : list of 2-tuples
317
+ bounds
318
318
A list ``[(a1, b1), (a2, b2)]`` containing bounds,
319
319
one per dimension.
320
- loss_per_triangle : callable, optional
320
+ loss_per_triangle
321
321
A function that returns the loss for every triangle.
322
322
If not provided, then a default is used, which uses
323
323
the deviation from a linear estimate, as well as
@@ -424,19 +424,19 @@ def to_dataframe(
424
424
425
425
Parameters
426
426
----------
427
- with_default_function_args : bool, optional
427
+ with_default_function_args
428
428
Include the ``learner.function``'s default arguments as a
429
429
column, by default True
430
- function_prefix : str, optional
430
+ function_prefix
431
431
Prefix to the ``learner.function``'s default arguments' names,
432
432
by default "function."
433
- seed_name : str, optional
433
+ seed_name
434
434
Name of the seed parameter, by default "seed"
435
- x_name : str, optional
435
+ x_name
436
436
Name of the input x value, by default "x"
437
- y_name : str, optional
437
+ y_name
438
438
Name of the input y value, by default "y"
439
- z_name : str, optional
439
+ z_name
440
440
Name of the output value, by default "z"
441
441
442
442
Returns
@@ -475,18 +475,18 @@ def load_dataframe(
475
475
476
476
Parameters
477
477
----------
478
- df : pandas.DataFrame
478
+ df
479
479
The data to load.
480
- with_default_function_args : bool, optional
480
+ with_default_function_args
481
481
The ``with_default_function_args`` used in ``to_dataframe()``,
482
482
by default True
483
- function_prefix : str, optional
483
+ function_prefix
484
484
The ``function_prefix`` used in ``to_dataframe``, by default "function."
485
- x_name : str, optional
485
+ x_name
486
486
The ``x_name`` used in ``to_dataframe``, by default "x"
487
- y_name : str, optional
487
+ y_name
488
488
The ``y_name`` used in ``to_dataframe``, by default "y"
489
- z_name : str, optional
489
+ z_name
490
490
The ``z_name`` used in ``to_dataframe``, by default "z"
491
491
"""
492
492
data = df .set_index ([x_name , y_name ])[z_name ].to_dict ()
@@ -538,7 +538,7 @@ def interpolated_on_grid(
538
538
539
539
Parameters
540
540
----------
541
- n : int, optional
541
+ n
542
542
Number of points in x and y. If None (default) this number is
543
543
evaluated by looking at the size of the smallest triangle.
544
544
@@ -611,14 +611,14 @@ def interpolator(self, *, scaled: bool = False) -> LinearNDInterpolator:
611
611
612
612
Parameters
613
613
----------
614
- scaled : bool
614
+ scaled
615
615
Use True if all points are inside the
616
616
unit-square [(-0.5, 0.5), (-0.5, 0.5)] or False if
617
617
the data points are inside the ``learner.bounds``.
618
618
619
619
Returns
620
620
-------
621
- interpolator : `scipy.interpolate.LinearNDInterpolator`
621
+ interpolator
622
622
623
623
Examples
624
624
--------
@@ -755,7 +755,7 @@ def remove_unfinished(self) -> None:
755
755
if p not in self .data :
756
756
self ._stack [p ] = np .inf
757
757
758
- def plot (self , n = None , tri_alpha = 0 ):
758
+ def plot (self , n : int = None , tri_alpha : float = 0 ):
759
759
r"""Plot the Learner2D's current state.
760
760
761
761
This plot function interpolates the data on a regular grid.
@@ -764,10 +764,10 @@ def plot(self, n=None, tri_alpha=0):
764
764
765
765
Parameters
766
766
----------
767
- n : int
767
+ n
768
768
Number of points in x and y. If None (default) this number is
769
769
evaluated by looking at the size of the smallest triangle.
770
- tri_alpha : float
770
+ tri_alpha
771
771
The opacity ``(0 <= tri_alpha <= 1)`` of the triangles overlayed
772
772
on top of the image. By default the triangulation is not visible.
773
773
0 commit comments