HunterMcGushion/hyperparameter_hunter

View on GitHub

Showing 89 of 104 total issues

Function format_fold_run has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

def format_fold_run(rep=None, fold=None, run=None, mode="concise"):
    """Construct a string to display the repetition, fold, and run currently being executed

    Parameters
    ----------
Severity: Minor
Found in hyperparameter_hunter/i_o/reporting.py - About 6 hrs 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 ask has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    def ask(self, n_points=None, strategy="cl_min"):  # TODO: Try `n_points` default=1
        """Request point (or points) at which objective should be evaluated next

        Parameters
        ----------
Severity: Minor
Found in hyperparameter_hunter/optimization/backends/skopt/engine.py - About 4 hrs 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

Environment has 37 functions (exceeds 20 allowed). Consider refactoring.
Open

class Environment:
    DEFAULT_PARAMS = dict(
        environment_params_path=None,
        results_path=None,
        target_column="target",
Severity: Minor
Found in hyperparameter_hunter/environment.py - About 4 hrs to fix

    Function lambda_callback has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

    def lambda_callback(
        on_exp_start=None,
        on_exp_end=None,
        on_rep_start=None,
        on_rep_end=None,
    Severity: Minor
    Found in hyperparameter_hunter/callbacks/bases.py - About 4 hrs 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 _tell has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        def _tell(self, x, y, fit=True):
            """Perform the actual work of incorporating one or more new points. See :meth:`tell` for
            the full description. This method exists to give access to the internals of adding points
            by side-stepping all input validation and transformation"""
            #################### Collect Search Points and Evaluations ####################
    Severity: Minor
    Found in hyperparameter_hunter/optimization/backends/skopt/engine.py - About 3 hrs 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 handle_complex_types has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle_complex_types(self):
            """Locate complex types in :attr:`parameters`, create hashes for them, add lookup entries
            linking their original values to their hashes, then update their values in
            :attr:`parameters` to their hashes to facilitate Description saving"""
            dataframe_hashes = {}
    Severity: Minor
    Found in hyperparameter_hunter/keys/makers.py - About 3 hrs 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 _check_y_is_valid has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        def _check_y_is_valid(self, x, y):
            """Check if the shapes and types of `x` and `y` are consistent. Complains if anything
            is weird about `y`"""
            #################### Per-Second Acquisition Function ####################
            if self.acq_func.endswith("ps"):
    Severity: Minor
    Found in hyperparameter_hunter/optimization/backends/skopt/engine.py - About 3 hrs 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 validate_fe_steps has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    def validate_fe_steps(
        candidate: Union[list, FeatureEngineer], template: Union[list, FeatureEngineer]
    ) -> list:
        """Check `candidate` "feature_engineer" `steps` compatibility with `template` and sanitize
        `candidate`
    Severity: Minor
    Found in hyperparameter_hunter/i_o/result_reader.py - About 3 hrs 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 link_choice_ids has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def link_choice_ids(layers, compile_params, extra_params, dimensions):
        """Update `extra_params` to include a "location" attribute on any descendants of
        :class:`space.Dimension`, specifying its position among all hyperparameters
    
        Parameters
    Severity: Minor
    Found in hyperparameter_hunter/compat/keras_optimization_helper.py - About 2 hrs 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 consolidate_layers has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def consolidate_layers(layers, class_name_key=True, split_args=False):
        """For each of the layer dicts in `layers`, merge the dict's keys to reflect the end value of
        the key, rather than its default value, and whether a value was explicitly given
    
        Parameters
    Severity: Minor
    Found in hyperparameter_hunter/compat/keras_optimization_helper.py - About 2 hrs 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 print_tree has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def print_tree(start_path, depth=-1, pretty=True):
        """Print directory/file tree structure
    
        Parameters
        ----------
    Severity: Minor
    Found in hyperparameter_hunter/utils/file_utils.py - About 2 hrs 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

    BaseOptPro has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class BaseOptPro(metaclass=MergedOptProMeta):
        source_script: str
    
        def __init__(
            self,
    Severity: Minor
    Found in hyperparameter_hunter/optimization/protocol_core.py - About 2 hrs to fix

      Dimension has 21 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Dimension(ABC):
          prior = None  # Prevent plotting from breaking on `Integer`, which has no `prior`
      
          def __init__(self, **kwargs):
              """Abstract base class for hyperparameter search space dimensions
      Severity: Minor
      Found in hyperparameter_hunter/space/dimensions.py - About 2 hrs to fix

        Function _validate_metrics_list_parameters has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def _validate_metrics_list_parameters(self):
                """Ensure metrics lists input parameters are correct types and compatible with each other"""
                for (_d_type, _m_val) in [(_, getattr(self, f"_ScoringMixIn{_}")) for _ in data_types]:
                    if _m_val == "all":
                        setattr(self, f"_ScoringMixIn{_d_type}", list(self.metrics.keys()))
        Severity: Minor
        Found in hyperparameter_hunter/metrics.py - About 2 hrs 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 format_metrics has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        def format_metrics(metrics: Union[Dict, List]) -> Dict[str, Metric]:
            """Properly format iterable `metrics` to contain instances of :class:`Metric`
        
            Parameters
            ----------
        Severity: Minor
        Found in hyperparameter_hunter/metrics.py - About 2 hrs 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 lambda_check_train_targets has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        def lambda_check_train_targets(
            on_exp_start: Optional[List[TrainTargetChunk]] = None,
            on_rep_start: Optional[List[TrainTargetChunk]] = None,
            on_fold_start: Optional[List[TrainTargetChunk]] = None,
            on_run_start: Optional[List[TrainTargetChunk]] = None,
        Severity: Minor
        Found in hyperparameter_hunter/callbacks/recipes.py - About 2 hrs 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 has_experiment_result_file has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        def has_experiment_result_file(results_dir, experiment_id, result_type=None):
            """Check if the specified result files exist in `results_dir` for Experiment `experiment_id`
        
            Parameters
            ----------
        Severity: Minor
        Found in hyperparameter_hunter/i_o/result_reader.py - About 2 hrs 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 get_concise_params_dict has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_concise_params_dict(params, split_args=False):
            # TODO: Add docstring
            new_params = subdict(params, drop=HH_ARG_ATTRS)
            arg_vals = {}
        
        
        Severity: Minor
        Found in hyperparameter_hunter/compat/keras_helper.py - About 2 hrs 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 check_dimension has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        def check_dimension(dimension, transform=None):
            """Turn a provided dimension description into a dimension object. Checks that the provided
            dimension falls into one of the supported types, listed below in the description of `dimension`
        
            Parameters
        Severity: Minor
        Found in hyperparameter_hunter/space/space_core.py - About 2 hrs 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 cook_estimator has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        def cook_estimator(base_estimator, space=None, **kwargs):
            """Cook a default estimator
        
            For the special `base_estimator` called "DUMMY", the return value is None. This corresponds to
            sampling points at random, hence there is no need for an estimator
        Severity: Minor
        Found in hyperparameter_hunter/optimization/backends/skopt/engine.py - About 1 hr 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