class_docstr: Array/scalar parameter
  
  Parameters
  ----------
  init: np.ndarray, or None
      initial value of the array (defaults to 0, with a provided shape)
  shape: tuple of ints, or None
      shape of the array, to be provided iff init is not provided
  lower: array, float or None
      minimum value
  upper: array, float or None
      maximum value
  mutable_sigma: bool
      whether the mutation standard deviation must mutate as well (for mutation based algorithms)
  
  Note
  ----
  - More specific behaviors can be obtained throught the following methods:
    set_bounds, set_mutation, set_integer_casting
  - if both lower and upper bounds are provided, sigma will be adapted so that the range spans 6 sigma.
    Also, if init is not provided, it will be set to the middle value.
class_docstr_tok: ["Array\/scalar","parameter","Parameters","--","--","--","--","--","init",":","np.ndarray",",","or","None","initial","value","of","the","array","(","defaults","to","0",",","with","a","provided","shape",")","shape",":","tuple","of","ints",",","or","None","shape","of","the","array",",","to","be","provided","iff","init","is","not","provided","lower",":","array",",","float","or","None","minimum","value","upper",":","array",",","float","or","None","maximum","value","mutable_sigma",":","bool","whether","the","mutation","standard","deviation","must","mutate","as","well","(","for","mutation","based","algorithms",")","Note","--","--","-","More","specific","behaviors","can","be","obtained","throught","the","following","methods",":","set_bounds",",","set_mutation",",","set_integer_casting","-","if","both","lower","and","upper","bounds","are","provided",",","sigma","will","be","adapted","so","that","the","range","spans","6","sigma",".","Also",",","if","init","is","not","provided",",","it","will","be","set","to","the","middle","value","."]
docstr: Bounds all real values into [lower, upper] using a provided method
  
  Parameters
  ----------
  lower: array, float or None
      minimum value
  upper: array, float or None
      maximum value
  method: str
      One of the following choices:
  
      - "bouncing": bounce on border (at most once). This is a variant of clipping,
         avoiding bounds over-samping (default).
      - "clipping": clips the values inside the bounds. This is efficient but leads
        to over-sampling on the bounds.
      - "constraint": adds a constraint (see register_cheap_constraint) which leads to rejecting mutations
        reaching beyond the bounds. This avoids oversampling the boundaries, but can be inefficient in large
        dimension.
      - "arctan": maps the space [lower, upper] to to all [-inf, inf] using arctan transform. This is efficient
        but it completely reshapes the space (a mutation in the center of the space will be larger than a mutation
        close to the bounds), and reaching the bounds is equivalent to reaching the infinity.
      - "tanh": same as "arctan", but with a "tanh" transform. "tanh" saturating much faster than "arctan", it can lead
        to unexpected behaviors.
  full_range_sampling: Optional bool
      Changes the default behavior of the "sample" method (aka creating a child and mutating it from the current instance)
      or the sampling optimizers, to creating a child with a value sampled uniformly (or log-uniformly) within
      the while range of the bounds. The "sample" method is used by some algorithms to create an initial population.
      This is activated by default if both bounds are provided.
  
  Notes
  -----
  - "tanh" reaches the boundaries really quickly, while "arctan" is much softer
  - only "clipping" accepts partial bounds (None values)
docstr_tok: ["Bounds","all","real","values","into","[","lower",",","upper","]","using","a","provided","method","Parameters","--","--","--","--","--","lower",":","array",",","float","or","None","minimum","value","upper",":","array",",","float","or","None","maximum","value","method",":","str","One","of","the","following","choices",":","-","``","bouncing","''",":","bounce","on","border","(","at","most","once",")",".","This","is","a","variant","of","clipping",",","avoiding","bounds","over-samping","(","default",")",".","-","``","clipping","''",":","clips","the","values","inside","the","bounds",".","This","is","efficient","but","leads","to","over-sampling","on","the","bounds",".","-","``","constraint","''",":","adds","a","constraint","(","see","register_cheap_constraint",")","which","leads","to","rejecting","mutations","reaching","beyond","the","bounds",".","This","avoids","oversampling","the","boundaries",",","but","can","be","inefficient","in","large","dimension",".","-","``","arctan","''",":","maps","the","space","[","lower",",","upper","]","to","to","all","[","-inf",",","inf","]","using","arctan","transform",".","This","is","efficient","but","it","completely","reshapes","the","space","(","a","mutation","in","the","center","of","the","space","will","be","larger","than","a","mutation","close","to","the","bounds",")",",","and","reaching","the","bounds","is","equivalent","to","reaching","the","infinity",".","-","``","tanh","''",":","same","as","``","arctan","''",",","but","with","a","``","tanh","''","transform",".","``","tanh","''","saturating","much","faster","than","``","arctan","''",",","it","can","lead","to","unexpected","behaviors",".","full_range_sampling",":","Optional","bool","Changes","the","default","behavior","of","the","``","sample","''","method","(","aka","creating","a","child","and","mutating","it","from","the","current","instance",")","or","the","sampling","optimizers",",","to","creating","a","child","with","a","value","sampled","uniformly","(","or","log-uniformly",")","within","the","while","range","of","the","bounds",".","The","``","sample","''","method","is","used","by","some","algorithms","to","create","an","initial","population",".","This","is","activated","by","default","if","both","bounds","are","provided",".","Notes","--","--","-","-","``","tanh","''","reaches","the","boundaries","really","quickly",",","while","``","arctan","''","is","much","softer","-","only","``","clipping","''","accepts","partial","bounds","(","None","values",")"]
code: def set_bounds(
      self: D,
      lower: tp.BoundValue = None,
      upper: tp.BoundValue = None,
      method: str = "bouncing",
      full_range_sampling: tp.Optional[bool] = None,
  ) -> D:
      """Bounds all real values into [lower, upper] using a provided method
  
      Parameters
      ----------
      lower: array, float or None
          minimum value
      upper: array, float or None
          maximum value
      method: str
          One of the following choices:
  
          - "bouncing": bounce on border (at most once). This is a variant of clipping,
             avoiding bounds over-samping (default).
          - "clipping": clips the values inside the bounds. This is efficient but leads
            to over-sampling on the bounds.
          - "constraint": adds a constraint (see register_cheap_constraint) which leads to rejecting mutations
            reaching beyond the bounds. This avoids oversampling the boundaries, but can be inefficient in large
            dimension.
          - "arctan": maps the space [lower, upper] to to all [-inf, inf] using arctan transform. This is efficient
            but it completely reshapes the space (a mutation in the center of the space will be larger than a mutation
            close to the bounds), and reaching the bounds is equivalent to reaching the infinity.
          - "tanh": same as "arctan", but with a "tanh" transform. "tanh" saturating much faster than "arctan", it can lead
            to unexpected behaviors.
      full_range_sampling: Optional bool
          Changes the default behavior of the "sample" method (aka creating a child and mutating it from the current instance)
          or the sampling optimizers, to creating a child with a value sampled uniformly (or log-uniformly) within
          the while range of the bounds. The "sample" method is used by some algorithms to create an initial population.
          This is activated by default if both bounds are provided.
  
      Notes
      -----
      - "tanh" reaches the boundaries really quickly, while "arctan" is much softer
      - only "clipping" accepts partial bounds (None values)
      """  # TODO improve description of methods
      from . import _datalayers
  
      # if method == "constraint":
      #     method = "clipping"
      value = self.value
      if method == "constraint":
          layer = _datalayers.BoundLayer(
              lower=lower,
              upper=upper,
              uniform_sampling=full_range_sampling,
          )
          checker = utils.BoundChecker(*layer.bounds)
          self.register_cheap_constraint(checker)
      else:
          layer = _datalayers.Bound(
              lower=lower,
              upper=upper,
              method=method,
              uniform_sampling=full_range_sampling,
          )
      layer._LEGACY = True
      layer(self, inplace=True)
      _fix_legacy(self)
      try:
          self.value = value
      except ValueError as e:
          raise errors.NevergradValueError(
              "Current value is not within bounds, please update it first"
          ) from e
      return self
  
imports: import numpy
  import nevergrad.common.typing
  from nevergrad.common import errors
  from .None import _layering
  from .None import core
  from .container import Dict
  from .None import utils
label_desc: Use image node_id 7 for calling the Data obj's underlying member method code with example usage: obj.set_bounds(lower, upper, method, full_range_sampling) and returns: self