tensorflow/models

View on GitHub
research/lfads/run_lfads.py

Summary

Maintainability
D
1 day
Test Coverage

File run_lfads.py has 547 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Copyright 2017 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
Severity: Major
Found in research/lfads/run_lfads.py - About 1 day to fix

    Function build_hyperparameter_dict has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def build_hyperparameter_dict(flags):
      """Simple script for saving hyper parameters.  Under the hood the
      flags structure isn't a dictionary, so it has to be simplified since we
      want to be able to view file as text.
    
    
    Severity: Major
    Found in research/lfads/run_lfads.py - About 2 hrs to fix

      Function build_model has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      def build_model(hps, kind="train", datasets=None):
        """Builds a model from either random initialization, or saved parameters.
      
        Args:
          hps: The hyper parameters for the model.
      Severity: Minor
      Found in research/lfads/run_lfads.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 main has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def main(_):
        """Get this whole shindig off the ground."""
        d = build_hyperparameter_dict(FLAGS)
        hps = hps_dict_to_obj(d)    # hyper parameters
        kind = FLAGS.kind
      Severity: Minor
      Found in research/lfads/run_lfads.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 load_datasets has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def load_datasets(data_dir, data_filename_stem):
        """Load the datasets from a specified directory.
      
        Example files look like
          >data_dir/my_dataset_first_day
      Severity: Minor
      Found in research/lfads/run_lfads.py - About 35 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 jsonify_dict has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def jsonify_dict(d):
        """Turns python booleans into strings so hps dict can be written in json.
        Creates a shallow-copied dictionary first, then accomplishes string
        conversion.
      
      
      Severity: Minor
      Found in research/lfads/run_lfads.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 write_model_samples has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def write_model_samples(hps, datasets, dataset_name=None, output_fname=None):
        """Use the prior distribution to generate samples from the model.
        Generates batch_size number of samples (set through FLAGS).
      
        LFADS generates a number of outputs for each examples, and these are all
      Severity: Minor
      Found in research/lfads/run_lfads.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