@@ -88,10 +88,10 @@ class BaseRunner(metaclass=abc.ABCMeta):
88
88
Convenience argument, use instead of ``goal``. The end condition for the
89
89
calculation. Stop when the current time is larger or equal than this
90
90
value.
91
- timedelta_goal : timedelta or int , optional
91
+ duration_goal : timedelta or number , optional
92
92
Convenience argument, use instead of ``goal``. The end condition for the
93
93
calculation. Stop when the current time is larger or equal than
94
- ``start_time + timedelta_goal ``.
94
+ ``start_time + duration_goal ``.
95
95
executor : `concurrent.futures.Executor`, `distributed.Client`,\
96
96
`mpi4py.futures.MPIPoolExecutor`, `ipyparallel.Client` or\
97
97
`loky.get_reusable_executor`, optional
@@ -148,7 +148,7 @@ def __init__(
148
148
loss_goal : float | None = None ,
149
149
npoints_goal : int | None = None ,
150
150
datetime_goal : datetime | None = None ,
151
- timedelta_goal : timedelta | None = None ,
151
+ duration_goal : timedelta | None = None ,
152
152
executor = None ,
153
153
ntasks = None ,
154
154
log = False ,
@@ -165,7 +165,7 @@ def __init__(
165
165
loss_goal ,
166
166
npoints_goal ,
167
167
datetime_goal ,
168
- timedelta_goal ,
168
+ duration_goal ,
169
169
allow_running_forever ,
170
170
)
171
171
@@ -423,7 +423,7 @@ def __init__(
423
423
loss_goal : float | None = None ,
424
424
npoints_goal : int | None = None ,
425
425
datetime_goal : datetime | None = None ,
426
- timedelta_goal : timedelta | None = None ,
426
+ duration_goal : timedelta | None = None ,
427
427
executor = None ,
428
428
ntasks = None ,
429
429
log = False ,
@@ -439,7 +439,7 @@ def __init__(
439
439
loss_goal = loss_goal ,
440
440
npoints_goal = npoints_goal ,
441
441
datetime_goal = datetime_goal ,
442
- timedelta_goal = timedelta_goal ,
442
+ duration_goal = duration_goal ,
443
443
executor = executor ,
444
444
ntasks = ntasks ,
445
445
log = log ,
@@ -507,10 +507,10 @@ class AsyncRunner(BaseRunner):
507
507
Convenience argument, use instead of ``goal``. The end condition for the
508
508
calculation. Stop when the current time is larger or equal than this
509
509
value.
510
- timedelta_goal : timedelta or int , optional
510
+ duration_goal : timedelta or number , optional
511
511
Convenience argument, use instead of ``goal``. The end condition for the
512
512
calculation. Stop when the current time is larger or equal than
513
- ``start_time + timedelta_goal ``.
513
+ ``start_time + duration_goal ``.
514
514
executor : `concurrent.futures.Executor`, `distributed.Client`,\
515
515
`mpi4py.futures.MPIPoolExecutor`, `ipyparallel.Client` or\
516
516
`loky.get_reusable_executor`, optional
@@ -581,7 +581,7 @@ def __init__(
581
581
loss_goal : float | None = None ,
582
582
npoints_goal : int | None = None ,
583
583
datetime_goal : datetime | None = None ,
584
- timedelta_goal : timedelta | None = None ,
584
+ duration_goal : timedelta | None = None ,
585
585
executor = None ,
586
586
ntasks = None ,
587
587
log = False ,
@@ -613,7 +613,7 @@ def __init__(
613
613
loss_goal = loss_goal ,
614
614
npoints_goal = npoints_goal ,
615
615
datetime_goal = datetime_goal ,
616
- timedelta_goal = timedelta_goal ,
616
+ duration_goal = duration_goal ,
617
617
executor = executor ,
618
618
ntasks = ntasks ,
619
619
log = log ,
@@ -800,7 +800,7 @@ def simple(
800
800
loss_goal : float | None = None ,
801
801
npoints_goal : int | None = None ,
802
802
datetime_goal : datetime | None = None ,
803
- timedelta_goal : timedelta | None = None ,
803
+ duration_goal : timedelta | None = None ,
804
804
):
805
805
"""Run the learner until the goal is reached.
806
806
@@ -831,18 +831,18 @@ def simple(
831
831
Convenience argument, use instead of ``goal``. The end condition for the
832
832
calculation. Stop when the current time is larger or equal than this
833
833
value.
834
- timedelta_goal : timedelta or int , optional
834
+ duration_goal : timedelta or number , optional
835
835
Convenience argument, use instead of ``goal``. The end condition for the
836
836
calculation. Stop when the current time is larger or equal than
837
- ``start_time + timedelta_goal ``.
837
+ ``start_time + duration_goal ``.
838
838
"""
839
839
goal = _goal (
840
840
learner ,
841
841
goal ,
842
842
loss_goal ,
843
843
npoints_goal ,
844
844
datetime_goal ,
845
- timedelta_goal ,
845
+ duration_goal ,
846
846
allow_running_forever = False ,
847
847
)
848
848
while not goal (learner ):
@@ -970,8 +970,8 @@ def _get_ncores(ex):
970
970
971
971
972
972
class _TimeGoal :
973
- def __init__ (self , dt : timedelta | datetime | int ):
974
- if isinstance (dt , int ):
973
+ def __init__ (self , dt : timedelta | datetime | int | float ):
974
+ if not isinstance (dt , ( timedelta , datetime ) ):
975
975
self .dt = timedelta (seconds = dt )
976
976
self .dt = dt
977
977
self .start_time = None
@@ -983,15 +983,15 @@ def __call__(self, _):
983
983
return datetime .now () - self .start_time > self .dt
984
984
if isinstance (self .dt , datetime ):
985
985
return datetime .now () > self .dt
986
- raise TypeError (f"`dt={ self .dt } ` is not a datetime or timedelta ." )
986
+ raise TypeError (f"`dt={ self .dt } ` is not a datetime, timedelta, or number ." )
987
987
988
988
989
989
def auto_goal (
990
990
* ,
991
991
loss : float | None = None ,
992
992
npoints : int | None = None ,
993
993
datetime : datetime | None = None ,
994
- timedelta : timedelta | int | None = None ,
994
+ duration : timedelta | int | None = None ,
995
995
learner : BaseLearner | None = None ,
996
996
allow_running_forever : bool = True ,
997
997
) -> Callable [[BaseLearner ], bool ]:
@@ -1005,7 +1005,7 @@ def auto_goal(
1005
1005
TODO
1006
1006
datetime
1007
1007
TODO
1008
- timedelta
1008
+ duration
1009
1009
TODO
1010
1010
learner
1011
1011
Learner for which to determine the goal.
@@ -1021,13 +1021,13 @@ def auto_goal(
1021
1021
loss = loss ,
1022
1022
npoints = npoints ,
1023
1023
datetime = datetime ,
1024
- timedelta = timedelta ,
1024
+ duration = duration ,
1025
1025
allow_running_forever = allow_running_forever ,
1026
1026
)
1027
- opts = (loss , npoints , datetime , timedelta ) # all are mutually exclusive
1027
+ opts = (loss , npoints , datetime , duration ) # all are mutually exclusive
1028
1028
if sum (v is not None for v in opts ) > 1 :
1029
1029
raise ValueError (
1030
- "Only one of loss, npoints, datetime, timedelta can be specified."
1030
+ "Only one of loss, npoints, datetime, duration can be specified."
1031
1031
)
1032
1032
1033
1033
if loss is not None :
@@ -1042,8 +1042,8 @@ def auto_goal(
1042
1042
return lambda learner : learner .npoints >= npoints
1043
1043
if datetime is not None :
1044
1044
return _TimeGoal (datetime )
1045
- if timedelta is not None :
1046
- return _TimeGoal (timedelta )
1045
+ if duration is not None :
1046
+ return _TimeGoal (duration )
1047
1047
if isinstance (learner , DataSaver ):
1048
1048
return auto_goal (** kw , learner = learner .learner )
1049
1049
if all (v is None for v in opts ):
@@ -1067,7 +1067,7 @@ def _goal(
1067
1067
loss_goal : float | None ,
1068
1068
npoints_goal : int | None ,
1069
1069
datetime_goal : datetime | None ,
1070
- timedelta_goal : timedelta | None ,
1070
+ duration_goal : timedelta | None ,
1071
1071
allow_running_forever : bool ,
1072
1072
):
1073
1073
if callable (goal ):
@@ -1077,17 +1077,17 @@ def _goal(
1077
1077
loss_goal is not None
1078
1078
or npoints_goal is not None
1079
1079
or datetime_goal is not None
1080
- or timedelta_goal is not None
1080
+ or duration_goal is not None
1081
1081
):
1082
1082
raise ValueError (
1083
1083
"Either goal, loss_goal, npoints_goal, datetime_goal or"
1084
- " timedelta_goal can be specified, not multiple."
1084
+ " duration_goal can be specified, not multiple."
1085
1085
)
1086
1086
return auto_goal (
1087
1087
learner = learner ,
1088
1088
loss = loss_goal ,
1089
1089
npoints = npoints_goal ,
1090
1090
datetime = datetime_goal ,
1091
- timedelta = timedelta_goal ,
1091
+ duration = duration_goal ,
1092
1092
allow_running_forever = allow_running_forever ,
1093
1093
)
0 commit comments