Skip to content

Commit f63c92b

Browse files
committed
Remove type-hints in doc-strings in runner.py
1 parent f27bf7e commit f63c92b

File tree

1 file changed

+62
-61
lines changed

1 file changed

+62
-61
lines changed

adaptive/runner.py

Lines changed: 62 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -104,23 +104,23 @@ class BaseRunner(metaclass=abc.ABCMeta):
104104
105105
Parameters
106106
----------
107-
learner : `~adaptive.BaseLearner` instance
108-
goal : callable, optional
107+
learner
108+
goal
109109
The end condition for the calculation. This function must take
110110
the learner as its sole argument, and return True when we should
111111
stop requesting more points.
112-
loss_goal : float, optional
112+
loss_goal
113113
Convenience argument, use instead of ``goal``. The end condition for the
114114
calculation. Stop when the loss is smaller than this value.
115-
npoints_goal : int, optional
115+
npoints_goal
116116
Convenience argument, use instead of ``goal``. The end condition for the
117117
calculation. Stop when the number of points is larger or
118118
equal than this value.
119-
end_time_goal : datetime, optional
119+
end_time_goal
120120
Convenience argument, use instead of ``goal``. The end condition for the
121121
calculation. Stop when the current time is larger or equal than this
122122
value.
123-
duration_goal : timedelta or number, optional
123+
duration_goal
124124
Convenience argument, use instead of ``goal``. The end condition for the
125125
calculation. Stop when the current time is larger or equal than
126126
``start_time + duration_goal``. ``duration_goal`` can be a number
@@ -131,22 +131,22 @@ class BaseRunner(metaclass=abc.ABCMeta):
131131
The executor in which to evaluate the function to be learned.
132132
If not provided, a new `~concurrent.futures.ProcessPoolExecutor` on
133133
Linux, and a `loky.get_reusable_executor` on MacOS and Windows.
134-
ntasks : int, optional
134+
ntasks
135135
The number of concurrent function evaluations. Defaults to the number
136136
of cores available in `executor`.
137-
log : bool, default: False
137+
log
138138
If True, record the method calls made to the learner by this runner.
139-
shutdown_executor : bool, default: False
139+
shutdown_executor
140140
If True, shutdown the executor when the runner has completed. If
141141
`executor` is not provided then the executor created internally
142142
by the runner is shut down, regardless of this parameter.
143-
retries : int, default: 0
143+
retries
144144
Maximum amount of retries of a certain point ``x`` in
145145
``learner.function(x)``. After `retries` is reached for ``x``
146146
the point is present in ``runner.failed``.
147-
raise_if_retries_exceeded : bool, default: True
147+
raise_if_retries_exceeded
148148
Raise the error after a point ``x`` failed `retries`.
149-
allow_running_forever : bool, default: False
149+
allow_running_forever
150150
Allow the runner to run forever when the goal is None.
151151
152152
Attributes
@@ -182,7 +182,7 @@ def __init__(
182182
npoints_goal: int | None = None,
183183
end_time_goal: datetime | None = None,
184184
duration_goal: timedelta | int | float | None = None,
185-
executor: (ExecutorTypes | None) = None,
185+
executor: ExecutorTypes | None = None,
186186
ntasks: int = None,
187187
log: bool = False,
188188
shutdown_executor: bool = False,
@@ -391,23 +391,23 @@ class BlockingRunner(BaseRunner):
391391
392392
Parameters
393393
----------
394-
learner : `~adaptive.BaseLearner` instance
395-
goal : callable, optional
394+
learner
395+
goal
396396
The end condition for the calculation. This function must take
397397
the learner as its sole argument, and return True when we should
398398
stop requesting more points.
399-
loss_goal : float, optional
399+
loss_goal
400400
Convenience argument, use instead of ``goal``. The end condition for the
401401
calculation. Stop when the loss is smaller than this value.
402-
npoints_goal : int, optional
402+
npoints_goal
403403
Convenience argument, use instead of ``goal``. The end condition for the
404404
calculation. Stop when the number of points is larger or
405405
equal than this value.
406-
end_time_goal : datetime, optional
406+
end_time_goal
407407
Convenience argument, use instead of ``goal``. The end condition for the
408408
calculation. Stop when the current time is larger or equal than this
409409
value.
410-
duration_goal : timedelta or number, optional
410+
duration_goal
411411
Convenience argument, use instead of ``goal``. The end condition for the
412412
calculation. Stop when the current time is larger or equal than
413413
``start_time + duration_goal``. ``duration_goal`` can be a number
@@ -418,20 +418,20 @@ class BlockingRunner(BaseRunner):
418418
The executor in which to evaluate the function to be learned.
419419
If not provided, a new `~concurrent.futures.ProcessPoolExecutor` on
420420
Linux, and a `loky.get_reusable_executor` on MacOS and Windows.
421-
ntasks : int, optional
421+
ntasks
422422
The number of concurrent function evaluations. Defaults to the number
423423
of cores available in `executor`.
424-
log : bool, default: False
424+
log
425425
If True, record the method calls made to the learner by this runner.
426-
shutdown_executor : bool, default: False
426+
shutdown_executor
427427
If True, shutdown the executor when the runner has completed. If
428428
`executor` is not provided then the executor created internally
429429
by the runner is shut down, regardless of this parameter.
430-
retries : int, default: 0
430+
retries
431431
Maximum amount of retries of a certain point ``x`` in
432432
``learner.function(x)``. After `retries` is reached for ``x``
433433
the point is present in ``runner.failed``.
434-
raise_if_retries_exceeded : bool, default: True
434+
raise_if_retries_exceeded
435435
Raise the error after a point ``x`` failed `retries`.
436436
437437
Attributes
@@ -471,7 +471,7 @@ def __init__(
471471
npoints_goal: int | None = None,
472472
end_time_goal: datetime | None = None,
473473
duration_goal: timedelta | int | float | None = None,
474-
executor: (ExecutorTypes | None) = None,
474+
executor: ExecutorTypes | None = None,
475475
ntasks: int | None = None,
476476
log: bool = False,
477477
shutdown_executor: bool = False,
@@ -536,25 +536,25 @@ class AsyncRunner(BaseRunner):
536536
537537
Parameters
538538
----------
539-
learner : `~adaptive.BaseLearner` instance
540-
goal : callable, optional
539+
learner
540+
goal
541541
The end condition for the calculation. This function must take
542542
the learner as its sole argument, and return True when we should
543543
stop requesting more points.
544544
If not provided, the runner will run forever (or stop when no more
545545
points can be added), or until ``runner.task.cancel()`` is called.
546-
loss_goal : float, optional
546+
loss_goal
547547
Convenience argument, use instead of ``goal``. The end condition for the
548548
calculation. Stop when the loss is smaller than this value.
549-
npoints_goal : int, optional
549+
npoints_goal
550550
Convenience argument, use instead of ``goal``. The end condition for the
551551
calculation. Stop when the number of points is larger or
552552
equal than this value.
553-
end_time_goal : datetime, optional
553+
end_time_goal
554554
Convenience argument, use instead of ``goal``. The end condition for the
555555
calculation. Stop when the current time is larger or equal than this
556556
value.
557-
duration_goal : timedelta or number, optional
557+
duration_goal
558558
Convenience argument, use instead of ``goal``. The end condition for the
559559
calculation. Stop when the current time is larger or equal than
560560
``start_time + duration_goal``. ``duration_goal`` can be a number
@@ -565,25 +565,25 @@ class AsyncRunner(BaseRunner):
565565
The executor in which to evaluate the function to be learned.
566566
If not provided, a new `~concurrent.futures.ProcessPoolExecutor` on
567567
Linux, and a `loky.get_reusable_executor` on MacOS and Windows.
568-
ntasks : int, optional
568+
ntasks
569569
The number of concurrent function evaluations. Defaults to the number
570570
of cores available in `executor`.
571-
log : bool, default: False
571+
log
572572
If True, record the method calls made to the learner by this runner.
573-
shutdown_executor : bool, default: False
573+
shutdown_executor
574574
If True, shutdown the executor when the runner has completed. If
575575
`executor` is not provided then the executor created internally
576576
by the runner is shut down, regardless of this parameter.
577577
ioloop : ``asyncio.AbstractEventLoop``, optional
578578
The ioloop in which to run the learning algorithm. If not provided,
579579
the default event loop is used.
580-
retries : int, default: 0
580+
retries
581581
Maximum amount of retries of a certain point ``x`` in
582582
``learner.function(x)``. After `retries` is reached for ``x``
583583
the point is present in ``runner.failed``.
584-
raise_if_retries_exceeded : bool, default: True
584+
raise_if_retries_exceeded
585585
Raise the error after a point ``x`` failed `retries`.
586-
allow_running_forever : bool, default: True
586+
allow_running_forever
587587
If True, the runner will run forever if the goal is not provided.
588588
589589
Attributes
@@ -630,7 +630,7 @@ def __init__(
630630
npoints_goal: int | None = None,
631631
end_time_goal: datetime | None = None,
632632
duration_goal: timedelta | int | float | None = None,
633-
executor: (ExecutorTypes | None) = None,
633+
executor: ExecutorTypes | None = None,
634634
ntasks: int | None = None,
635635
log: bool = False,
636636
shutdown_executor: bool = False,
@@ -736,22 +736,21 @@ def live_plot(
736736
737737
Parameters
738738
----------
739-
runner : `~adaptive.Runner`
740-
plotter : function
739+
plotter
741740
A function that takes the learner as a argument and returns a
742741
holoviews object. By default ``learner.plot()`` will be called.
743-
update_interval : int
742+
update_interval
744743
Number of second between the updates of the plot.
745-
name : hasable
744+
name
746745
Name for the `live_plot` task in `adaptive.active_plotting_tasks`.
747746
By default the name is None and if another task with the same name
748747
already exists that other `live_plot` is canceled.
749-
normalize : bool
748+
normalize
750749
Normalize (scale to fit) the frame upon each update.
751750
752751
Returns
753752
-------
754-
dm : `holoviews.core.DynamicMap`
753+
dm
755754
The plot that automatically updates every `update_interval`.
756755
"""
757756
return live_plot(
@@ -811,12 +810,12 @@ def start_periodic_saving(
811810
812811
Parameters
813812
----------
814-
save_kwargs : dict
813+
save_kwargs
815814
Key-word arguments for ``learner.save(**save_kwargs)``.
816815
Only used if ``method=None``.
817-
interval : int
816+
interval
818817
Number of seconds between saving the learner.
819-
method : callable
818+
method
820819
The method to use for saving the learner. If None, the default
821820
saves the learner using "pickle" which calls
822821
``learner.save(**save_kwargs)``. Otherwise provide a callable
@@ -874,23 +873,23 @@ def simple(
874873
875874
Parameters
876875
----------
877-
learner : ~`adaptive.BaseLearner` instance
878-
goal : callable, optional
876+
learner
877+
goal
879878
The end condition for the calculation. This function must take
880879
the learner as its sole argument, and return True when we should
881880
stop requesting more points.
882-
loss_goal : float, optional
881+
loss_goal
883882
Convenience argument, use instead of ``goal``. The end condition for the
884883
calculation. Stop when the loss is smaller than this value.
885-
npoints_goal : int, optional
884+
npoints_goal
886885
Convenience argument, use instead of ``goal``. The end condition for the
887886
calculation. Stop when the number of points is larger or
888887
equal than this value.
889-
end_time_goal : datetime, optional
888+
end_time_goal
890889
Convenience argument, use instead of ``goal``. The end condition for the
891890
calculation. Stop when the current time is larger or equal than this
892891
value.
893-
duration_goal : timedelta or number, optional
892+
duration_goal
894893
Convenience argument, use instead of ``goal``. The end condition for the
895894
calculation. Stop when the current time is larger or equal than
896895
``start_time + duration_goal``. ``duration_goal`` can be a number
@@ -922,9 +921,9 @@ def replay_log(
922921
923922
Parameters
924923
----------
925-
learner : `~adaptive.BaseLearner` instance
924+
learner
926925
New learner where the log will be applied.
927-
log : list
926+
log
928927
contains tuples: ``(method_name, *args)``.
929928
"""
930929
for method, *args in log:
@@ -980,7 +979,9 @@ def _get_ncores(
980979
# --- Useful runner goals
981980

982981
# TODO: deprecate
983-
def stop_after(*, seconds=0, minutes=0, hours=0) -> Callable[[BaseLearner], bool]:
982+
def stop_after(
983+
*, seconds: float = 0, minutes: float = 0, hours: float = 0
984+
) -> Callable[[BaseLearner], bool]:
984985
"""Stop a runner after a specified time.
985986
986987
For example, to specify a runner that should stop after
@@ -1000,7 +1001,7 @@ def stop_after(*, seconds=0, minutes=0, hours=0) -> Callable[[BaseLearner], bool
10001001
10011002
Returns
10021003
-------
1003-
goal : callable
1004+
goal
10041005
Can be used as the ``goal`` parameter when constructing
10051006
a `Runner`.
10061007
@@ -1042,13 +1043,13 @@ def auto_goal(
10421043
10431044
Parameters
10441045
----------
1045-
loss : float, optional
1046+
loss
10461047
Stop when the loss is smaller than this value.
1047-
npoints : int, optional
1048+
npoints
10481049
Stop when the number of points is larger or equal than this value.
1049-
end_time : datetime, optional
1050+
end_time
10501051
Stop when the current time is larger or equal than this value.
1051-
duration : timedelta or number, optional
1052+
duration
10521053
Stop when the current time is larger or equal than
10531054
``start_time + duration``. ``duration`` can be a number
10541055
indicating the number of seconds.

0 commit comments

Comments
 (0)