Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 45 additions & 54 deletions xdeps/optimize/optimize.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import copy
import re
import logging
import re
from warnings import warn

import numpy as np
from scipy.optimize import least_squares
from scipy.optimize import minimize, direct
from ..general import _print
from scipy.optimize import direct, least_squares, minimize

from .jacobian import JacobianSolver
from ..general import _print
from ..table import Table
from .jacobian import JacobianSolver

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -1536,7 +1536,7 @@ def enable_vary(self, id=None, tag=None):
"""
Enable one or more variables.

Deprecated. Please use enable(vary=id_or_tags).
.. warning:: Deprecated. Please use :meth:`enable` passing ``id`` or ``tag``.

Parameters
----------
Expand All @@ -1545,17 +1545,17 @@ def enable_vary(self, id=None, tag=None):
tag : str or list of str, optional
Tag of the variable to disable.
"""
#log.warning(
# "WARNING: `enable_vary` will be deprecated."
# " Please use `enable(vary=id_or_tags)`."
#)
warn(
"The function `enable_vary` is deprecated, use `enable(vary=id_or_tags)`.",
FutureWarning,
)
self.enable(vary=_add_id_tag(id, tag))

def disable_vary(self, id=None, tag=None):
"""
Disable one or more variables.

Deprecated. Please use `disable(vary=id_or_tags)`.
.. warning:: Deprecated. Please use :meth:`disable` passing ``id`` or ``tag``.

Parameters
----------
Expand All @@ -1565,17 +1565,17 @@ def disable_vary(self, id=None, tag=None):
Tag of the variable to disable.
Str is interpreted as regular expression. Defaults to None.
"""
#log.warning(
# "WARNING: `disable_vary` will be deprecated."
# " Please use `disable(vary=id_or_tags)`."
#)
warn(
"The function `disable_vary` is deprecated, use `disable(vary=id_or_tags)`.",
FutureWarning,
)
self.disable(vary=_add_id_tag(id, tag))

def enable_targets(self, *id_or_tag, id=None, tag=None):
"""
Enable one or more targets.

Deprecated. Please use `enable(target=id_or_tags)` instead.
.. warning:: Deprecated. Please use :meth:`enable`.

Parameters
----------
Expand All @@ -1588,18 +1588,17 @@ def enable_targets(self, *id_or_tag, id=None, tag=None):
Tag of the targets to disable.
Str is interpreted as regular expression. Defaults to None.
"""
#log.warning(
# "WARNING: `enable_targets` will be deprecated."
# " Please use `enable(target=id_or_tags)`."
#)

warn(
"The function `enable_targets` is deprecated, use `enable(target=id_or_tags)`.",
FutureWarning,
)
self.enable(target=_add_id_tag(id, tag))

def disable_targets(self, id=None, tag=None):
"""
Disable one or more targets.

Deprecated. Use `disable(target=id_or_tags)` instead.
.. warning:: Deprecated. Please use :meth:`disable` passing ``id`` or ``tag``.

Parameters
----------
Expand All @@ -1609,39 +1608,35 @@ def disable_targets(self, id=None, tag=None):
Tag of the targets to disable.
Str is interpreted as regular expression. Defaults to None.
"""
#log.warning(
# "WARNING: `disable_targets` will be deprecated."
# " Please use `disable(target=ids_or_tags)`."
#)
warn(
"The function `disable_targets` is deprecated, use `disable(target=ids_or_tags)`.",
FutureWarning,
)
self.disable(target=_add_id_tag(id, tag))

def disable_all_targets(self):
"""
Disable all targets.

Deprecated. Please use `disable(target=True)`.
.. warning:: Deprecated. Please use :meth:`disable` with ``target=True``.
"""

#log.warning(
# "WARNING: `disable_all_targets` will be deprecated."
# " Please use `disable(target=True)."
#)

warn(
"The function `disable_all_targets` is deprecated, use `disable(target=True).",
FutureWarning,
)
for tt in self.targets:
tt.active = False

def enable_all_targets(self):
"""
Enable all targets.

Deprecated. Please use `enable(target=True)`.
.. warning:: Deprecated. Please use :meth:`enable` with ``target=True``.
"""

#log.warning(
# "WARNING: `enable_all_targets` will be deprecated."
# " Please use `enable(target=True)."
#)

warn(
"The function `enable_all_targets` is deprecated, use `enable(target=True).",
FutureWarning,
)
for tt in self.targets:
tt.active = True
return self
Expand All @@ -1650,14 +1645,12 @@ def disable_all_vary(self):
"""
Disable all knobs.

Deprecated. Please use `disable(vary=True)`.
.. warning:: Deprecated. Please use :meth:`disable` with ``vary=True``.
"""

#log.warning(
# "WARNING: `disable_all_vary` will be deprecated."
# " Please use `disable(vary=True)."
#)

warn(
"The function `disable_all_vary` is deprecated, use `disable(vary=True).",
FutureWarning,
)
for vv in self.vary:
vv.active = False
return self
Expand All @@ -1666,14 +1659,12 @@ def enable_all_vary(self):
"""
Enable all knobs.

Deprecated. Please use `enable(vary=True)`.
.. warning:: Deprecated. Please use :meth:`enable` with ``vary=True``.
"""

#log.warning(
# "WARNING: `enable_all_vary` will be deprecated."
# " Please use `enable(vary=True)."
#)

warn(
"The function `enable_all_vary` is deprecated, use `enable(vary=True).",
FutureWarning,
)
for vv in self.vary:
vv.active = True
return self
Expand Down