@@ -88,10 +88,10 @@ class BaseRunner(metaclass=abc.ABCMeta):
8888 Convenience argument, use instead of ``goal``. The end condition for the
8989 calculation. Stop when the current time is larger or equal than this
9090 value.
91- timedelta_goal : timedelta or int , optional
91+ duration_goal : timedelta or number , optional
9292 Convenience argument, use instead of ``goal``. The end condition for the
9393 calculation. Stop when the current time is larger or equal than
94- ``start_time + timedelta_goal ``.
94+ ``start_time + duration_goal ``.
9595 executor : `concurrent.futures.Executor`, `distributed.Client`,\
9696 `mpi4py.futures.MPIPoolExecutor`, `ipyparallel.Client` or\
9797 `loky.get_reusable_executor`, optional
@@ -148,7 +148,7 @@ def __init__(
148148 loss_goal : float | None = None ,
149149 npoints_goal : int | None = None ,
150150 datetime_goal : datetime | None = None ,
151- timedelta_goal : timedelta | None = None ,
151+ duration_goal : timedelta | None = None ,
152152 executor = None ,
153153 ntasks = None ,
154154 log = False ,
@@ -165,7 +165,7 @@ def __init__(
165165 loss_goal ,
166166 npoints_goal ,
167167 datetime_goal ,
168- timedelta_goal ,
168+ duration_goal ,
169169 allow_running_forever ,
170170 )
171171
@@ -423,7 +423,7 @@ def __init__(
423423 loss_goal : float | None = None ,
424424 npoints_goal : int | None = None ,
425425 datetime_goal : datetime | None = None ,
426- timedelta_goal : timedelta | None = None ,
426+ duration_goal : timedelta | None = None ,
427427 executor = None ,
428428 ntasks = None ,
429429 log = False ,
@@ -439,7 +439,7 @@ def __init__(
439439 loss_goal = loss_goal ,
440440 npoints_goal = npoints_goal ,
441441 datetime_goal = datetime_goal ,
442- timedelta_goal = timedelta_goal ,
442+ duration_goal = duration_goal ,
443443 executor = executor ,
444444 ntasks = ntasks ,
445445 log = log ,
@@ -507,10 +507,10 @@ class AsyncRunner(BaseRunner):
507507 Convenience argument, use instead of ``goal``. The end condition for the
508508 calculation. Stop when the current time is larger or equal than this
509509 value.
510- timedelta_goal : timedelta or int , optional
510+ duration_goal : timedelta or number , optional
511511 Convenience argument, use instead of ``goal``. The end condition for the
512512 calculation. Stop when the current time is larger or equal than
513- ``start_time + timedelta_goal ``.
513+ ``start_time + duration_goal ``.
514514 executor : `concurrent.futures.Executor`, `distributed.Client`,\
515515 `mpi4py.futures.MPIPoolExecutor`, `ipyparallel.Client` or\
516516 `loky.get_reusable_executor`, optional
@@ -581,7 +581,7 @@ def __init__(
581581 loss_goal : float | None = None ,
582582 npoints_goal : int | None = None ,
583583 datetime_goal : datetime | None = None ,
584- timedelta_goal : timedelta | None = None ,
584+ duration_goal : timedelta | None = None ,
585585 executor = None ,
586586 ntasks = None ,
587587 log = False ,
@@ -613,7 +613,7 @@ def __init__(
613613 loss_goal = loss_goal ,
614614 npoints_goal = npoints_goal ,
615615 datetime_goal = datetime_goal ,
616- timedelta_goal = timedelta_goal ,
616+ duration_goal = duration_goal ,
617617 executor = executor ,
618618 ntasks = ntasks ,
619619 log = log ,
@@ -800,7 +800,7 @@ def simple(
800800 loss_goal : float | None = None ,
801801 npoints_goal : int | None = None ,
802802 datetime_goal : datetime | None = None ,
803- timedelta_goal : timedelta | None = None ,
803+ duration_goal : timedelta | None = None ,
804804):
805805 """Run the learner until the goal is reached.
806806
@@ -831,18 +831,18 @@ def simple(
831831 Convenience argument, use instead of ``goal``. The end condition for the
832832 calculation. Stop when the current time is larger or equal than this
833833 value.
834- timedelta_goal : timedelta or int , optional
834+ duration_goal : timedelta or number , optional
835835 Convenience argument, use instead of ``goal``. The end condition for the
836836 calculation. Stop when the current time is larger or equal than
837- ``start_time + timedelta_goal ``.
837+ ``start_time + duration_goal ``.
838838 """
839839 goal = _goal (
840840 learner ,
841841 goal ,
842842 loss_goal ,
843843 npoints_goal ,
844844 datetime_goal ,
845- timedelta_goal ,
845+ duration_goal ,
846846 allow_running_forever = False ,
847847 )
848848 while not goal (learner ):
@@ -970,8 +970,8 @@ def _get_ncores(ex):
970970
971971
972972class _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 ) ):
975975 self .dt = timedelta (seconds = dt )
976976 self .dt = dt
977977 self .start_time = None
@@ -983,15 +983,15 @@ def __call__(self, _):
983983 return datetime .now () - self .start_time > self .dt
984984 if isinstance (self .dt , datetime ):
985985 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 ." )
987987
988988
989989def auto_goal (
990990 * ,
991991 loss : float | None = None ,
992992 npoints : int | None = None ,
993993 datetime : datetime | None = None ,
994- timedelta : timedelta | int | None = None ,
994+ duration : timedelta | int | None = None ,
995995 learner : BaseLearner | None = None ,
996996 allow_running_forever : bool = True ,
997997) -> Callable [[BaseLearner ], bool ]:
@@ -1005,7 +1005,7 @@ def auto_goal(
10051005 TODO
10061006 datetime
10071007 TODO
1008- timedelta
1008+ duration
10091009 TODO
10101010 learner
10111011 Learner for which to determine the goal.
@@ -1021,13 +1021,13 @@ def auto_goal(
10211021 loss = loss ,
10221022 npoints = npoints ,
10231023 datetime = datetime ,
1024- timedelta = timedelta ,
1024+ duration = duration ,
10251025 allow_running_forever = allow_running_forever ,
10261026 )
1027- opts = (loss , npoints , datetime , timedelta ) # all are mutually exclusive
1027+ opts = (loss , npoints , datetime , duration ) # all are mutually exclusive
10281028 if sum (v is not None for v in opts ) > 1 :
10291029 raise ValueError (
1030- "Only one of loss, npoints, datetime, timedelta can be specified."
1030+ "Only one of loss, npoints, datetime, duration can be specified."
10311031 )
10321032
10331033 if loss is not None :
@@ -1042,8 +1042,8 @@ def auto_goal(
10421042 return lambda learner : learner .npoints >= npoints
10431043 if datetime is not None :
10441044 return _TimeGoal (datetime )
1045- if timedelta is not None :
1046- return _TimeGoal (timedelta )
1045+ if duration is not None :
1046+ return _TimeGoal (duration )
10471047 if isinstance (learner , DataSaver ):
10481048 return auto_goal (** kw , learner = learner .learner )
10491049 if all (v is None for v in opts ):
@@ -1067,7 +1067,7 @@ def _goal(
10671067 loss_goal : float | None ,
10681068 npoints_goal : int | None ,
10691069 datetime_goal : datetime | None ,
1070- timedelta_goal : timedelta | None ,
1070+ duration_goal : timedelta | None ,
10711071 allow_running_forever : bool ,
10721072):
10731073 if callable (goal ):
@@ -1077,17 +1077,17 @@ def _goal(
10771077 loss_goal is not None
10781078 or npoints_goal is not None
10791079 or datetime_goal is not None
1080- or timedelta_goal is not None
1080+ or duration_goal is not None
10811081 ):
10821082 raise ValueError (
10831083 "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."
10851085 )
10861086 return auto_goal (
10871087 learner = learner ,
10881088 loss = loss_goal ,
10891089 npoints = npoints_goal ,
10901090 datetime = datetime_goal ,
1091- timedelta = timedelta_goal ,
1091+ duration = duration_goal ,
10921092 allow_running_forever = allow_running_forever ,
10931093 )
0 commit comments