kjappelbaum/pyepal

View on GitHub
src/pyepal/pal/validate_inputs.py

Summary

Maintainability
D
1 day
Test Coverage

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Open

    assert alpha > 0
Severity: Info
Found in src/pyepal/pal/validate_inputs.py by bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Open

        assert len(clean_goals) == ndim
Severity: Info
Found in src/pyepal/pal/validate_inputs.py by bandit

Function validate_goals has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

def validate_goals(goals: Any, ndim: int) -> np.ndarray:  # pylint:disable=too-many-branches
    """Create a valid array of goals. 1 for maximization, -1
        for objectives that are to be minimized.

    Args:
Severity: Minor
Found in src/pyepal/pal/validate_inputs.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

File validate_inputs.py has 329 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
# Copyright 2020 PyePAL authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Severity: Minor
Found in src/pyepal/pal/validate_inputs.py - About 3 hrs to fix

    Function validate_epsilon has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def validate_epsilon(epsilon: Any, ndim: int) -> np.ndarray:
        """Validate epsilon and return a np.array
    
        Args:
            epsilon (Any): Epsilon hyperparameter
    Severity: Minor
    Found in src/pyepal/pal/validate_inputs.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 validate_gbdt_models has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def validate_gbdt_models(models: Any, ndim: int) -> List[Iterable]:
        """Make sure that the number of iterables is equal to the number of objectives
        and that every iterable contains three LGBMRegressors.
        Also, we check that at least the first and last models use quantile loss"""
    
    
    Severity: Minor
    Found in src/pyepal/pal/validate_inputs.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

    Function validate_positive_integer_list has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def validate_positive_integer_list(
        seq: Any, ndim: int, parameter_name: str = "Parameter"
    ) -> Sequence[int]:
        """Can be used, e.g., to validate and standardize the ensemble size
        and epochs input"""
    Severity: Minor
    Found in src/pyepal/pal/validate_inputs.py - About 55 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_nt_models has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def validate_nt_models(models: Any, ndim: int) -> Sequence:
        """Make sure that we can work with a sequence of
        :py:func:`pyepal.pal.models.nt.NTModel`"""
        from pyepal.models.nt import NTModel  # pylint:disable=import-outside-toplevel
    
    
    Severity: Minor
    Found in src/pyepal/pal/validate_inputs.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_sklearn_gpr_model has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def _validate_sklearn_gpr_model(model: Any) -> GaussianProcessRegressor:
        """Make sure that we deal with a GaussianProcessRegressor instance,
        if it is a fitted random or grid search instance, extract the model"""
        if isinstance(model, (RandomizedSearchCV, GridSearchCV)):
            try:
    Severity: Minor
    Found in src/pyepal/pal/validate_inputs.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

    There are no issues that match your filters.

    Category
    Status