Skip to content

Commit

Permalink
Bring back space.{un}pack_point but deprecate them
Browse files Browse the repository at this point in the history
Why:

The plugin orion.skopt.algo is relying on these functions so we need to
keep them unlees we update the plugin.

How:

Call the new methods internally and log a warning that {un}pack_point
will be removed in v0.2.0.
  • Loading branch information
bouthilx committed Jul 23, 2019
1 parent 9091106 commit f80d007
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/orion/algo/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,17 @@
"""

from collections import OrderedDict
import logging
import numbers

import numpy
from scipy.stats import distributions

from orion.core.utils.points import flatten_dims, regroup_dims


logger = logging.getLogger(__name__)


def check_random_state(seed):
"""Return numpy global rng or RandomState if seed is specified"""
Expand Down Expand Up @@ -818,3 +824,25 @@ def __repr__(self):
"""Represent as a string the space and the dimensions it contains."""
dims = list(self.values())
return "Space([{}])".format(',\n '.join(map(str, dims)))


def pack_point(point, space):
"""Take a list of points and pack it appropriately as a point from `space`.
This function is deprecated and will be removed in v0.2.0. Use
`orion.core.utils.points.regroup_dims` instead.
"""
logger.warning('`pack_point` is deprecated and will be removed in v0.2.0. Use '
'`orion.core.utils.points.regroup_dims` instead.')
return regroup_dims(point, space)


def unpack_point(point, space):
"""Flatten `point` in `space` and convert it to a 1D `numpy.ndarray`.
This function is deprecated and will be removed in v0.2.0. Use
`orion.core.utils.points.flatten_dims` instead.
"""
logger.warning('`unpack_point` is deprecated and will be removed in v0.2.0. Use '
'`orion.core.utils.points.regroup_dims` instead.')
return flatten_dims(point, space)

0 comments on commit f80d007

Please sign in to comment.