kjappelbaum/pyepal

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

Summary

Maintainability
B
4 hrs
Test Coverage

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

    assert (
        len(X) > n_samples
    ), "The numbers of points that shall be selected (n_samples),\
         needs to be smaller than the length of the feature matrix (X)"

Severity: Info
Found in src/pyepal/pal/utils.py by bandit

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

    assert n_samples > 0 and isinstance(
        n_samples, int
    ), "The number of points that shall be selected (n_samples)\
             needs to be an integer greater than 0"

Severity: Info
Found in src/pyepal/pal/utils.py by bandit

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

    assert palinstance.number_design_points == len(
        y
    ), "The number of points in the design space must equal the number of measurements"
Severity: Info
Found in src/pyepal/pal/utils.py by bandit

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

    assert (
        len(X) > n_samples
    ), "The numbers of points that shall be selected (n_samples),\
         needs to be smaller than the length of the feature matrix (X)"

Severity: Info
Found in src/pyepal/pal/utils.py by bandit

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

    assert n_samples > 0 and isinstance(
        n_samples, int
    ), "The number of points that shall be selected (n_samples)\
         needs to be an integer greater than 0"

Severity: Info
Found in src/pyepal/pal/utils.py by bandit

File utils.py has 257 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/utils.py - About 2 hrs to fix

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

    def get_maxmin_samples(  # pylint:disable=invalid-name
    Severity: Major
    Found in src/pyepal/pal/utils.py - About 50 mins to fix

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

      def dominance_check_jitted_3(array: np.array, point: np.array, ignore_me: int) -> bool:
          """Check if any point in array dominates point. ignore_me
          since numba does not understand masked arrays"""
          sorted_idx = array[:, 0].argsort()[::-1]
          ignore_me = np.where(sorted_idx == ignore_me)[0][0]
      Severity: Minor
      Found in src/pyepal/pal/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 get_nondimensional_pareto_error has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_nondimensional_pareto_error(
          y_true: np.ndarray, y_pred: np.ndarray, ranges: np.ndarray
      ) -> float:
          """Calculates a non-dimensional error metric,
          the scaled minimum maximum average distance of a Pareto-optimal
      Severity: Minor
      Found in src/pyepal/pal/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 get_maxmin_samples has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_maxmin_samples(  # pylint:disable=invalid-name
          X: np.array,
          n_samples: int,
          metric: str = "euclidean",
          init: str = "mean",
      Severity: Minor
      Found in src/pyepal/pal/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

      There are no issues that match your filters.

      Category
      Status