Skip to content

Commit 7f26f51

Browse files
committed
Remove types in doc-strings in learner2D.py
1 parent 4d10f2f commit 7f26f51

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

adaptive/learner/learner2D.py

+38-38
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ def deviations(ip: LinearNDInterpolator) -> list[np.ndarray]:
4040
4141
Parameters
4242
----------
43-
ip : `scipy.interpolate.LinearNDInterpolator` instance
43+
ip
4444
4545
Returns
4646
-------
47-
deviations : list
47+
deviations
4848
The deviation per triangle.
4949
"""
5050
values = ip.values / (ip.values.ptp(axis=0).max() or 1)
@@ -79,11 +79,11 @@ def areas(ip: LinearNDInterpolator) -> np.ndarray:
7979
8080
Parameters
8181
----------
82-
ip : `scipy.interpolate.LinearNDInterpolator` instance
82+
ip
8383
8484
Returns
8585
-------
86-
areas : numpy.ndarray
86+
areas
8787
The area per triangle in ``ip.tri``.
8888
"""
8989
p = ip.tri.points[ip.tri.simplices]
@@ -99,11 +99,11 @@ def uniform_loss(ip: LinearNDInterpolator) -> np.ndarray:
9999
100100
Parameters
101101
----------
102-
ip : `scipy.interpolate.LinearNDInterpolator` instance
102+
ip
103103
104104
Returns
105105
-------
106-
losses : numpy.ndarray
106+
losses
107107
Loss per triangle in ``ip.tri``.
108108
109109
Examples
@@ -136,7 +136,7 @@ def resolution_loss_function(
136136
137137
Returns
138138
-------
139-
loss_function : callable
139+
loss_function
140140
141141
Examples
142142
--------
@@ -173,11 +173,11 @@ def minimize_triangle_surface_loss(ip: LinearNDInterpolator) -> np.ndarray:
173173
174174
Parameters
175175
----------
176-
ip : `scipy.interpolate.LinearNDInterpolator` instance
176+
ip
177177
178178
Returns
179179
-------
180-
losses : numpy.ndarray
180+
losses
181181
Loss per triangle in ``ip.tri``.
182182
183183
Examples
@@ -217,11 +217,11 @@ def default_loss(ip: LinearNDInterpolator) -> np.ndarray:
217217
218218
Parameters
219219
----------
220-
ip : `scipy.interpolate.LinearNDInterpolator` instance
220+
ip
221221
222222
Returns
223223
-------
224-
losses : numpy.ndarray
224+
losses
225225
Loss per triangle in ``ip.tri``.
226226
"""
227227
dev = np.sum(deviations(ip), axis=0)
@@ -241,15 +241,15 @@ def choose_point_in_triangle(triangle: np.ndarray, max_badness: int) -> np.ndarr
241241
242242
Parameters
243243
----------
244-
triangle : numpy.ndarray
244+
triangle
245245
The coordinates of a triangle with shape (3, 2).
246-
max_badness : int
246+
max_badness
247247
The badness at which the point is either chosen on a edge or
248248
in the middle.
249249
250250
Returns
251251
-------
252-
point : numpy.ndarray
252+
point
253253
The x and y coordinate of the suggested new point.
254254
"""
255255
a, b, c = triangle
@@ -267,17 +267,17 @@ def choose_point_in_triangle(triangle: np.ndarray, max_badness: int) -> np.ndarr
267267
return point
268268

269269

270-
def triangle_loss(ip):
270+
def triangle_loss(ip: LinearNDInterpolator) -> list[float]:
271271
r"""Computes the average of the volumes of the simplex combined with each
272272
neighbouring point.
273273
274274
Parameters
275275
----------
276-
ip : `scipy.interpolate.LinearNDInterpolator` instance
276+
ip
277277
278278
Returns
279279
-------
280-
triangle_loss : list
280+
triangle_loss
281281
The mean volume per triangle.
282282
283283
Notes
@@ -311,13 +311,13 @@ class Learner2D(BaseLearner):
311311
312312
Parameters
313313
----------
314-
function : callable
314+
function
315315
The function to learn. Must take a tuple of two real
316316
parameters and return a real number.
317-
bounds : list of 2-tuples
317+
bounds
318318
A list ``[(a1, b1), (a2, b2)]`` containing bounds,
319319
one per dimension.
320-
loss_per_triangle : callable, optional
320+
loss_per_triangle
321321
A function that returns the loss for every triangle.
322322
If not provided, then a default is used, which uses
323323
the deviation from a linear estimate, as well as
@@ -424,19 +424,19 @@ def to_dataframe(
424424
425425
Parameters
426426
----------
427-
with_default_function_args : bool, optional
427+
with_default_function_args
428428
Include the ``learner.function``'s default arguments as a
429429
column, by default True
430-
function_prefix : str, optional
430+
function_prefix
431431
Prefix to the ``learner.function``'s default arguments' names,
432432
by default "function."
433-
seed_name : str, optional
433+
seed_name
434434
Name of the seed parameter, by default "seed"
435-
x_name : str, optional
435+
x_name
436436
Name of the input x value, by default "x"
437-
y_name : str, optional
437+
y_name
438438
Name of the input y value, by default "y"
439-
z_name : str, optional
439+
z_name
440440
Name of the output value, by default "z"
441441
442442
Returns
@@ -475,18 +475,18 @@ def load_dataframe(
475475
476476
Parameters
477477
----------
478-
df : pandas.DataFrame
478+
df
479479
The data to load.
480-
with_default_function_args : bool, optional
480+
with_default_function_args
481481
The ``with_default_function_args`` used in ``to_dataframe()``,
482482
by default True
483-
function_prefix : str, optional
483+
function_prefix
484484
The ``function_prefix`` used in ``to_dataframe``, by default "function."
485-
x_name : str, optional
485+
x_name
486486
The ``x_name`` used in ``to_dataframe``, by default "x"
487-
y_name : str, optional
487+
y_name
488488
The ``y_name`` used in ``to_dataframe``, by default "y"
489-
z_name : str, optional
489+
z_name
490490
The ``z_name`` used in ``to_dataframe``, by default "z"
491491
"""
492492
data = df.set_index([x_name, y_name])[z_name].to_dict()
@@ -538,7 +538,7 @@ def interpolated_on_grid(
538538
539539
Parameters
540540
----------
541-
n : int, optional
541+
n
542542
Number of points in x and y. If None (default) this number is
543543
evaluated by looking at the size of the smallest triangle.
544544
@@ -611,14 +611,14 @@ def interpolator(self, *, scaled: bool = False) -> LinearNDInterpolator:
611611
612612
Parameters
613613
----------
614-
scaled : bool
614+
scaled
615615
Use True if all points are inside the
616616
unit-square [(-0.5, 0.5), (-0.5, 0.5)] or False if
617617
the data points are inside the ``learner.bounds``.
618618
619619
Returns
620620
-------
621-
interpolator : `scipy.interpolate.LinearNDInterpolator`
621+
interpolator
622622
623623
Examples
624624
--------
@@ -755,7 +755,7 @@ def remove_unfinished(self) -> None:
755755
if p not in self.data:
756756
self._stack[p] = np.inf
757757

758-
def plot(self, n=None, tri_alpha=0):
758+
def plot(self, n: int = None, tri_alpha: float = 0):
759759
r"""Plot the Learner2D's current state.
760760
761761
This plot function interpolates the data on a regular grid.
@@ -764,10 +764,10 @@ def plot(self, n=None, tri_alpha=0):
764764
765765
Parameters
766766
----------
767-
n : int
767+
n
768768
Number of points in x and y. If None (default) this number is
769769
evaluated by looking at the size of the smallest triangle.
770-
tri_alpha : float
770+
tri_alpha
771771
The opacity ``(0 <= tri_alpha <= 1)`` of the triangles overlayed
772772
on top of the image. By default the triangulation is not visible.
773773

0 commit comments

Comments
 (0)