HunterMcGushion/hyperparameter_hunter

View on GitHub

Showing 89 of 104 total issues

Function reinitialize_callbacks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def reinitialize_callbacks(callbacks):
    """Ensures the contents of `callbacks` are valid Keras callbacks

    Parameters
    ----------
Severity: Minor
Found in hyperparameter_hunter/compat/keras_helper.py - About 25 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 visit_Return has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def visit_Return(self, node):
        try:
            self.returns.append(node.value.id)
        except AttributeError:
            for element in node.value.elts:
Severity: Minor
Found in hyperparameter_hunter/feature_engineering.py - About 25 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 extract_imports has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def extract_imports(source):
    """(Taken from `hyperas.utils`). Construct a string containing all imports from `source`

    Parameters
    ----------
Severity: Minor
Found in hyperparameter_hunter/utils/parsing_utils.py - About 25 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 validate_environment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_environment(self):
        """Check that the currently active Environment is suitable"""
        if G.Env is None:
            raise EnvironmentInactiveError("")
        if not all([hasattr(G.Env, _) for _ in ["result_paths", "cross_experiment_key"]]):
Severity: Minor
Found in hyperparameter_hunter/keys/makers.py - About 25 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 extra_enter_attrs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def extra_enter_attrs(iter_attrs: Union[BooleanEnterFunc, List[BooleanEnterFunc]]) -> EnterFunc:
    """Build an `enter` function intended for use with `boltons_utils.remap` that enables entrance
    into non-standard objects defined by `iter_attrs` and iteration over their attributes as dicts

    Parameters
Severity: Minor
Found in hyperparameter_hunter/utils/general_utils.py - About 25 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 _validate_estimator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def _validate_estimator(estimator: EstTypes, *valid_values: EstTypes) -> Optional[bool]:
    # TODO: Add docstring
    for valid_value in valid_values:
        if isinstance(valid_value, str) and estimator == valid_value.upper():
            return True
Severity: Minor
Found in hyperparameter_hunter/optimization/backends/skopt/protocols.py - About 25 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 initialize_dummy_model has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def initialize_dummy_model(model_initializer, build_fn, wrapper_params):
    """Creates a dummy model with placeholder values wherever hyperparameter options are provided
    via `hyperparameter_hunter.space` classes in order to produce a valid Keras model, albeit one
    with semi-useless values, which also contains attributes injected by
    :mod:`hyperparameter_hunter.importer`, and :mod:`hyperparameter_hunter.tracers` in order to
Severity: Minor
Found in hyperparameter_hunter/compat/keras_optimization_helper.py - About 25 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 acq_optimizer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def acq_optimizer(self, value):
        # Decide optimizer based on gradient information
        if value == "auto":
            if has_gradients(self.base_estimator):
                value = "lbfgs"
Severity: Minor
Found in hyperparameter_hunter/optimization/backends/skopt/engine.py - About 25 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 subdict has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def subdict(d, keep=None, drop=None, key=None, value=None):
    """Compute the "subdictionary" of a dict, `d`

    Parameters
    ----------
Severity: Minor
Found in hyperparameter_hunter/utils/general_utils.py - About 25 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