darthdeus/bopt

View on GitHub

Showing 136 of 136 total issues

Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, param: bopt.Hyperparameter, x: List[float],
Severity: Major
Found in bopt/cli/web.py - About 1 hr to fix

    Function create_slice_1d has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def create_slice_1d(i: int, experiment: bopt.Experiment, resolution: int,
    Severity: Major
    Found in bopt/cli/web.py - About 1 hr to fix

      Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, job: Optional[Job],
      Severity: Major
      Found in bopt/sample.py - About 50 mins to fix

        Function acq_for_dims has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def acq_for_dims(model, acq: AcquisitionFunction, x_slice, hyperparameters, ax,
        Severity: Major
        Found in bopt/plot.py - About 50 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if sample.result is not None:
                                  print(sample.result)
          
          
          Severity: Major
          Found in bopt/cli/exp.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if value > self._separator_tops[i]:
                                        state += 1 + len(self._separators[i])
                                    else:
                                        state += np.digitize(value, self._separators[i])
                                states.append(self._first_tile_states + (t - 1) * self._rest_tiles_states + state)
            Severity: Major
            Found in experiments/rl/gym_evaluator.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if type in mapping:
                                      cls, parser = mapping[type]
                                  else:
                                      logging.error("Invalid value {} for hyperparameter type, "
                                                    "only 'int', 'float', 'logscale_int', 'logscale_float' "
              Severity: Major
              Found in bopt/cli/init.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        with open(fname, "r") as f:
                                            contents = f.read().rstrip("\n")
                                            found = False
                
                                            for line in contents.split("\n"):
                Severity: Major
                Found in bopt/experiment.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if i == j:
                                              slices_1d.append(create_slice_1d(i, experiment,
                                                  resolution, n_dims, x_slice, model, sample, show_marginal))
                  
                                          elif i < j:
                  Severity: Major
                  Found in bopt/cli/web.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        with open("meta.json", "w") as f_dst:
                                            import yaml
                                            import json
                    
                                            data = yaml.load(f_src, Loader=yaml.Loader)
                    Severity: Major
                    Found in bopt/cli/convert_meta.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if len(values) == 2:
                                              low, high = values
                                              buckets = -1
                                          elif len(values) == 3:
                                              low, high, buckets = values
                      Severity: Major
                      Found in bopt/cli/init.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if best_res is None or (sample.result and sample.result > best_res):
                                                    best_res = sample.result
                                                    best_sample = sample
                                            except ValueError:
                        Severity: Major
                        Found in bopt/cli/exp.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              for h, v in best_sample.hyperparam_values.mapping.items():
                                                  if isinstance(v, float):
                                                      v = round(v, 2)
                                                  run_str += " --{}={}".format(h.name, v)
                          
                          
                          Severity: Major
                          Found in bopt/cli/exp.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    for v, h in zip(value, experiment.hyperparameters):
                                                        kernel_param_timeline["{}_{}".format(key, h.name)].append(v)
                                                else:
                            Severity: Major
                            Found in bopt/cli/web.py - About 45 mins to fix

                              Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  def __init__(self, task_name: str, batch_name: Optional[str],
                              Severity: Minor
                              Found in bopt/experiment.py - About 45 mins to fix

                                Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    def __init__(self, name: str, type: Type[T], default: T, action: Optional[str], help: str):
                                Severity: Minor
                                Found in bopt/gp_config.py - About 35 mins to fix

                                  Function run_main has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  def run_main(args):
                                      parser = argparse.ArgumentParser(prog="bopt")
                                      parser.set_defaults()
                                  
                                      cd_parser = argparse.ArgumentParser(add_help=None)
                                  Severity: Minor
                                  Found in bopt/cli/cli.py - About 35 mins to fix

                                  Cognitive Complexity

                                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                  A method's cognitive complexity is based on a few simple rules:

                                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                  • Code is considered more complex for each "break in the linear flow of the code"
                                  • Code is considered more complex when "flow breaking structures are nested"

                                  Further reading

                                  Function gpy_regression has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      def gpy_regression(hyperparameters: List[Hyperparameter],
                                                         gp_config: GPConfig, X_sample: np.ndarray,
                                                         Y_sample: np.ndarray) -> GPRegression:
                                          kernel = GPyModel.create_kernel(gp_config.kernel, X_sample.shape[1], ARD=gp_config.ard)
                                  
                                  
                                  Severity: Minor
                                  Found in bopt/models/gpy_model.py - About 35 mins to fix

                                  Cognitive Complexity

                                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                  A method's cognitive complexity is based on a few simple rules:

                                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                  • Code is considered more complex for each "break in the linear flow of the code"
                                  • Code is considered more complex when "flow breaking structures are nested"

                                  Further reading

                                  Function propose_location has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      def propose_location(acquisition_fn: acq.AcquisitionFunction, gp:
                                                           GPRegression, y_max: float, hyperparameters: List[Hyperparameter],
                                                           gp_config: GPConfig) -> np.ndarray:
                                  
                                          def min_obj(X):
                                  Severity: Minor
                                  Found in bopt/models/gpy_model.py - About 35 mins to fix

                                  Cognitive Complexity

                                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                  A method's cognitive complexity is based on a few simple rules:

                                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                  • Code is considered more complex for each "break in the linear flow of the code"
                                  • Code is considered more complex when "flow breaking structures are nested"

                                  Further reading

                                  Function run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  def run(args) -> None:
                                      with handle_cd_revertible(args.dir):
                                          with ensure_meta_yml():
                                              logging.info("Found existing meta.yml, resuming experiment.")
                                  
                                  
                                  Severity: Minor
                                  Found in bopt/cli/run.py - About 35 mins to fix

                                  Cognitive Complexity

                                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                  A method's cognitive complexity is based on a few simple rules:

                                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                  • Code is considered more complex for each "break in the linear flow of the code"
                                  • Code is considered more complex when "flow breaking structures are nested"

                                  Further reading

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language