class_docstr: Class for parsing hyperparameters
class_docstr_tok: ["Class","for","parsing","hyperparameters"]
code: def _parse_grid(self, param_name, range_str):
      return_val = None
      if "," in range_str:
          # return numpy array for consistency with other cases
          return_val = np.array(
              [float(s) for s in range_str.split(",")]
          )
      elif ":" in range_str:
          range_limits = range_str.split(":")
          assert len(range_limits) > 1
          if len(range_limits) == 2:
              try:
                  limit1 = float(range_limits[0])
              except ValueError:
                  limit1 = 0.0
              limit2 = float(range_limits[1])
              return_val = np.arange(limit1, limit2 + 1)
          else:
              try:
                  limit1 = float(range_limits[0])
              except ValueError:
                  limit1 = 0.0
  
              limit3 = float(range_limits[2])
  
              try:
                  limit2 = float(range_limits[1])
                  if int(limit2) == limit2 and limit2 > abs(
                      limit3 - limit1
                  ):
                      return_val = np.linspace(
                          limit1, limit3, int(limit2)
                      )
                  else:
                      return_val = np.arange(
                          limit1, limit3 + 0.5 * limit2, limit2
                      )
  
              except ValueError:
                  if "l" in range_limits[1]:
                      limit2 = int(range_limits[1].replace("l", ""))
                      return_val = np.exp(
                          np.linspace(
                              np.log(limit1), np.log(limit3), limit2
                          )
                      )
                  else:
                      raise ValueError(
                          "unknown limit specification "
                          + range_limits[1]
                      )
  
      else:
          return_val = [float(range_str)]
      if not isinstance(return_val, list):
          return_val = return_val.tolist()
  
      if not hasattr(self, "index"):
          self.index = 0
      h = Hyperparameter(
          param_name, index=self.index, values=return_val
      )
      self.index += 1
      return h
  
file_path: studio/studio/hyperparameter.py
imports: import itertools
  import math
  import numpy
label_desc: Use image node_id 5 for calling the HyperparameterParser obj's underlying member method code with example usage: obj._parse_grid(param_name, range_str) and returns: h