Skip to content

GD raises deprecation warning if atol and rtol are not used #2054

Description

@hrobarts

Description

GD raises a deprecation warning if atol or rtol are passed and are !=0. But the default value if they're not passed is None so the deprecation warning is also raised if the arguments are not used at all.

self.rtol = kwargs.pop('rtol', None) # to be deprecated (released in 25.0)
self.atol = kwargs.pop('atol', None) # to be deprecated (released in 25.0)
if kwargs.get('objective_function') is not None: # to be deprecated
warn('The argument `objective_function` will be deprecated in the future. Please use `f` instead.', DeprecationWarning, stacklevel=2)
if f is not None:
raise ValueError('The argument `objective_function` is being deprecated, replaced by `f`. Please use just `f` not both')
f = kwargs.pop('objective_function')
if self.alpha is not None or self.beta is not None: # to be deprecated
warn('To modify the parameters for the Armijo rule please use `step_size_rule=ArmijoStepSizeRule(alpha, beta, kmax)`. The arguments `alpha` and `beta` will be deprecated. ', DeprecationWarning, stacklevel=2)
if self.rtol!=0 or self.atol!=0: # to be deprecated (released in 25.0)
warn('`rtol` and `atol` are deprecated. For early stopping, please use a callback (cil.optimisation.utilities.callbacks), for example `EarlyStoppingObjectiveValue`.', DeprecationWarning, stacklevel=2)
else:
log.warn('Breaking backwards compatibility, GD no longer automatically stops if the objective function is close to zero. For this functionality, please use a callback (cil.optimisation.utilities.callbacks).' )

myGD_LS = GD(initial=x0, 
             f=f1, 
             step_size=None,
             update_objective_interval=10)

DeprecationWarning: `rtol` and `atol` are deprecated. For early stopping, please use a callback (cil.optimisation.utilities.callbacks),  for example `EarlyStoppingObjectiveValue`.
  myGD_LS = GD(initial=x0,

Environment

import cil, sys
print(cil.version.version, cil.version.commit_hash, sys.version, sys.platform)

24.3.0 None 3.12.8 | packaged by conda-forge | (main, Dec 5 2024, 14:24:40) [GCC 13.3.0] linux

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions