docstr: Sets the particles a periodic fashion
  
  This method resets the particles that exeed the bounds by using the
  modulo function to cut down the position. This creates a virtual,
  periodic plane which is tiled with the search space.
  The following equation describtes this strategy:
  
  .. math::
      :nowrap:
  
      \begin{gather*}
      x_{i, t, d} = \begin{cases}
                          ub_d - (lb_d - x_{i, t, d}) \mod s_d & \quad \text{if }x_{i, t, d} < lb_d \\
                          lb_d + (x_{i, t, d} - ub_d) \mod s_d & \quad \text{if }x_{i, t, d} > ub_d \\
                          x_{i, t, d} & \quad \text{otherwise}
                    \end{cases}\\
      \\
      \text{with}\\
      \\
      s_d = |ub_d - lb_d|
      \end{gather*}
docstr_tok: ["Sets","the","particles","a","periodic","fashion","This","method","resets","the","particles","that","exeed","the","bounds","by","using","the","modulo","function","to","cut","down","the","position",".","This","creates","a","virtual",",","periodic","plane","which","is","tiled","with","the","search","space",".","The","following","equation","describtes","this","strategy",":","..","math",":",":",":","nowrap",":","\\begin","{","gather","*","}","x_","{","i",",","t",",","d","}","=","\\begin","{","cases","}","ub_d","-","(","lb_d","-","x_","{","i",",","t",",","d","}",")","\\mod","s_d","&","\\quad","\\text","{","if","}","x_","{","i",",","t",",","d","}","<","lb_d","\\\\","lb_d","+","(","x_","{","i",",","t",",","d","}","-","ub_d",")","\\mod","s_d","&","\\quad","\\text","{","if","}","x_","{","i",",","t",",","d","}",">","ub_d","\\\\","x_","{","i",",","t",",","d","}","&","\\quad","\\text","{","otherwise","}","\\end","{","cases","}","\\\\","\\\\","\\text","{","with","}","\\\\","\\\\","s_d","=","|ub_d","-","lb_d|","\\end","{","gather","*","}"]
code: def periodic(self, position, bounds, **kwargs):
      r"""Sets the particles a periodic fashion
  
          This method resets the particles that exeed the bounds by using the
          modulo function to cut down the position. This creates a virtual,
          periodic plane which is tiled with the search space.
          The following equation describtes this strategy:
  
          .. math::
              :nowrap:
  
              \begin{gather*}
              x_{i, t, d} = \begin{cases}
                                  ub_d - (lb_d - x_{i, t, d}) \mod s_d & \quad \text{if }x_{i, t, d} < lb_d \\
                                  lb_d + (x_{i, t, d} - ub_d) \mod s_d & \quad \text{if }x_{i, t, d} > ub_d \\
                                  x_{i, t, d} & \quad \text{otherwise}
                            \end{cases}\\
              \\
              \text{with}\\
              \\
              s_d = |ub_d - lb_d|
              \end{gather*}
  
          """
      lb, ub = bounds
      lower_than_bound, greater_than_bound = self._out_of_bounds(
          position, bounds
      )
      bound_d = np.tile(
          np.abs(np.array(ub) - np.array(lb)), (position.shape[0], 1)
      )
      ub = np.tile(ub, (position.shape[0], 1))
      lb = np.tile(lb, (position.shape[0], 1))
      new_pos = position
      if (
          lower_than_bound[0].size != 0
          and lower_than_bound[1].size != 0
      ):
          new_pos[lower_than_bound] = ub[lower_than_bound] - np.mod(
              (lb[lower_than_bound] - new_pos[lower_than_bound]),
              bound_d[lower_than_bound],
          )
      if (
          greater_than_bound[0].size != 0
          and greater_than_bound[1].size != 0
      ):
          new_pos[greater_than_bound] = lb[greater_than_bound] + np.mod(
              (new_pos[greater_than_bound] - ub[greater_than_bound]),
              bound_d[greater_than_bound],
          )
      return new_pos
  
imports: import inspect
  import logging
  import numpy
  import math
  from copy import copy
  from ..utils.reporter import Reporter
label_desc: Use image node_id 8 for calling the BoundaryHandler obj's underlying member method code with example usage: obj.periodic(position, bounds) and returns: new_pos