HazyResearch/numbskull

View on GitHub

Showing 154 of 497 total issues

Function eval_factor has a Cognitive Complexity of 224 (exceeds 5 allowed). Consider refactoring.
Open

def eval_factor(factor_id, var_samp, value, var_copy, variable, factor, fmap,
                var_value):
    """TODO."""
    ####################
    # BINARY VARIABLES #
Severity: Minor
Found in numbskull/inference.py - About 4 days 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 messages.py has 975 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""TODO."""

from __future__ import print_function
import numbskull
from numbskull.numbskulltypes import *
Severity: Major
Found in salt/src/messages.py - About 2 days to fix

    Function find_ufo has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
    Open

    def find_ufo(factor, factor_pt, factor_ufo, fmap, vid, variable, var_pt,
                 var_ufo, pf_ufo_var_list, pf_var_begin):
        # Count number of factors with UFO
        n_ufo_recv = 0  # Number of ufo to receive
        n_ufo_send = 0  # Number of ufo to send
    Severity: Minor
    Found in salt/src/messages.py - About 1 day 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 _set_tcp_keepalive has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
    Open

    def _set_tcp_keepalive(sock, opts):
        """Ensure that TCP keepalives are set for the socket."""
        if hasattr(socket, 'SO_KEEPALIVE'):
            if opts.get('tcp_keepalive', False):
                sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
    Severity: Minor
    Found in salt/src/numbskull_minion_server.py - About 1 day 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 compute_ufo_map has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
    Open

    def compute_ufo_map(factor, factor_pt, factor_ufo, fmap, vid, variable, var_pt, var_ufo, ufo_send, pf_ufo_var_list, pf_var_begin):
        ufo_length = np.zeros(ufo_send.size, np.int64)
        ufo_start = np.zeros(ufo_send.size + 1, np.int64)
        ufo = np.zeros(1, dtype=UnaryFactorOpt)
        if len(ufo_send) == 0:
    Severity: Minor
    Found in salt/src/messages.py - About 7 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 numbskull_master.py has 466 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    
    """TODO."""
    
    
    Severity: Minor
    Found in salt/src/numbskull_master.py - About 7 hrs to fix

      File numbskull_minion_server.py has 419 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """TODO."""
      
      # Import python libs
      from __future__ import absolute_import
      import logging
      Severity: Minor
      Found in salt/src/numbskull_minion_server.py - About 6 hrs to fix

        Function set_pf has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
        Open

        def set_pf(factor, factor_pt, factor_ufo, fmap, fid, vid, variable, var_pt, var_ufo, pf_var_begin, vid_max, ismaster, pf_ufo_var_list):
            # vid_max should just be np.iinfo(vid.dtype).max, but numba doesn't support iinfo   
        
            # Setting fake variables
            for i in range(pf_var_begin, len(vid)):
        Severity: Minor
        Found in salt/src/messages.py - About 5 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 compute_skipped_factors has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
        Open

        def compute_skipped_factors(factor, factor_pt, factor_ufo, fmap, fid, vid,
                                    variable, var_pt, var_ufo, pf_list, ismaster):
            n_pf_send = 0
            n_pf_skip = 0
            # n_ufo_skip = 0
        Severity: Minor
        Found in salt/src/messages.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

        File numbskull.py has 349 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        #!/usr/bin/env python
        
        """TODO: This is a docstring."""
        
        from __future__ import print_function, absolute_import
        Severity: Minor
        Found in numbskull/numbskull.py - About 4 hrs to fix

          Function compute_var_map has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

          def compute_var_map(variables, factors, fmap, vmap, factor_index, domain_mask,
                              factors_to_skip=np.empty(0, np.int64)):
              """TODO."""
              # Fill in domain values (for mapping when dumping marginals)
              for i, v in enumerate(variables):
          Severity: Minor
          Found in numbskull/dataloading.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 server has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

          def server(argv=None):
              """TODO."""
              parser = argparse.ArgumentParser(
                  description="Run Gibbs worker",
                  epilog="")
          Severity: Minor
          Found in numbskull/distributed.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 inference has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              def inference(self, epochs=1, learn=False):
                  """TODO."""
                  mode = "Learning" if learn else "Inference"
                  print("BEGINNING " + mode.upper())
                  begin = time.time()
          Severity: Minor
          Found in salt/src/numbskull_master.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 prepare_db has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

              def prepare_db(self, cur):
                  """TODO."""
                  # Run deepdive to perform candidate extraction
                  self.run_deepdive()
          
          
          Severity: Minor
          Found in salt/src/numbskull_master.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 inference.py has 311 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          """TODO."""
          
          from __future__ import print_function, absolute_import
          import numba
          from numba import jit
          Severity: Minor
          Found in numbskull/inference.py - About 3 hrs to fix

            File distributed.py has 308 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            #!/usr/bin/env python
            
            """TODO."""
            
            from __future__ import print_function
            Severity: Minor
            Found in numbskull/distributed.py - About 3 hrs to fix

              Function find_metis_parts has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
              Open

              def find_metis_parts(conn, cur, parts):
                  """TODO"""
                  # Open a cursor to perform database operations
                  (factor_view, variable_view, weight_view) = get_views(cur)
                  # Obtain graph
              Severity: Minor
              Found in salt/src/messages.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 sample_and_sgd has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
              Open

              def sample_and_sgd(var_samp, step, regularization, reg_param, truncation,
                                 var_copy, weight_copy, weight, variable, factor, fmap,
                                 vmap, factor_index, Z, fids, var_value, var_value_evid,
                                 weight_value, learn_non_evidence):
                  """TODO."""
              Severity: Minor
              Found in numbskull/learning.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 start has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

              def start():
                  """TODO."""
                  log.debug('Initializing Numbskull Minion Engine')
                  ns_minion = NumbskullMinion()
                  event_bus = salt.utils.event.get_event(
              Severity: Minor
              Found in salt/src/numbskull_minion.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 get_factors has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_factors(cur, views, sql_filter="True"):
                  """TODO."""
                  factors = 0
                  edges = 0
              
              
              Severity: Minor
              Found in salt/src/messages.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

              Severity
              Category
              Status
              Source
              Language