q-optimize/c3

View on GitHub

Showing 303 of 330 total issues

File chip.py has 1062 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Component class and subclasses for the components making up the quantum device."""
import copy
import warnings

import numpy as np
Severity: Major
Found in c3/libraries/chip.py - About 2 days to fix

    File devices.py has 988 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import os
    import tempfile
    import hjson
    from typing import Callable, Dict, Any, List
    import tensorflow as tf
    Severity: Major
    Found in c3/generator/devices.py - About 2 days to fix

      File propagation.py has 744 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      "A library for propagators and closely related functions"
      import numpy as np
      import tensorflow as tf
      from typing import Dict
      from c3.model import Model
      Severity: Major
      Found in c3/libraries/propagation.py - About 1 day to fix

        File fidelities.py has 715 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """Library of fidelity functions."""
        
        import numpy as np
        import tensorflow as tf
        from typing import List, Dict
        Severity: Major
        Found in c3/libraries/fidelities.py - About 1 day to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              gauss_params_single = {
                  "amp": Qty(value=0.45, min_val=0.35, max_val=0.6, unit="V"),
                  "t_final": Qty(
                      value=t_final, min_val=0.5 * t_final, max_val=1.5 * t_final, unit="s"
                  ),
          Severity: Major
          Found in examples/single_qubit_experiment.py and 1 other location - About 1 day to fix
          examples/single_qubit_blackbox_exp.py on lines 105..122

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 177.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          File model.py has 631 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          """The model class, containing information on the system and its modelling."""
          import warnings
          import numpy as np
          import hjson
          import itertools
          Severity: Major
          Found in c3/model.py - About 1 day to fix

            File experiment.py has 621 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            """
            Experiment class that models and simulates the whole experiment.
            
            It combines the information about the model of the quantum device, the control stack
            and the operations that can be done on the device.
            Severity: Major
            Found in c3/experiment.py - About 1 day to fix

              File algorithms.py has 561 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              """
              Collection of (optimization) algorithms. All entries share a common signature with
              optional arguments.
              """
              
              
              Severity: Major
              Found in c3/libraries/algorithms.py - About 1 day to fix

                File envelopes.py has 494 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                """
                Library of envelope functions.
                
                All functions assume the input of a time vector and return complex amplitudes.
                """
                Severity: Minor
                Found in c3/libraries/envelopes.py - About 7 hrs to fix

                  File qt_utils.py has 471 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  """Useful functions to get basis vectors and matrices of the right size."""
                  import itertools
                  import numpy as np
                  from typing import List
                  from scipy.linalg import block_diag as scipy_block_diag
                  Severity: Minor
                  Found in c3/utils/qt_utils.py - About 7 hrs to fix

                    File c3_backend.py has 468 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import uuid
                    import time
                    import numpy as np
                    import logging
                    import warnings
                    Severity: Minor
                    Found in c3/qiskit/c3_backend.py - About 7 hrs to fix

                      Identical blocks of code found in 2 locations. Consider refactoring.
                      Open

                          norm = tf.sqrt(2 * np.pi * sigma**2) * tf.math.erf(
                              t_final / (np.sqrt(8) * sigma)
                          ) - t_final * tf.exp(-(t_final**2) / (8 * sigma**2))
                      Severity: Major
                      Found in c3/libraries/envelopes.py and 1 other location - About 6 hrs to fix
                      c3/libraries/envelopes.py on lines 550..552

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 109.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Identical blocks of code found in 2 locations. Consider refactoring.
                      Open

                          norm = tf.sqrt(2 * np.pi * sigma**2) * tf.math.erf(
                              t_final / (np.sqrt(8) * sigma)
                          ) - t_final * tf.exp(-(t_final**2) / (8 * sigma**2))
                      Severity: Major
                      Found in c3/libraries/envelopes.py and 1 other location - About 6 hrs to fix
                      c3/libraries/envelopes.py on lines 525..527

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 109.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                      @deprecated("Using standard width. Better use gaussian_sigma().")
                      @env_reg_deco
                      def gaussian(t, params):
                          """
                          Normalized gaussian with fixed time/sigma ratio.
                      Severity: Major
                      Found in c3/libraries/envelopes.py and 1 other location - About 6 hrs to fix
                      c3/libraries/envelopes.py on lines 532..542

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 107.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                      @deprecated("Using standard width. Better use drag_sigma.")
                      @env_reg_deco
                      def drag(t, params):
                          """Second order gaussian with fixed time/sigma ratio."""
                          params["sigma"] = Qty(
                      Severity: Major
                      Found in c3/libraries/envelopes.py and 1 other location - About 6 hrs to fix
                      c3/libraries/envelopes.py on lines 399..417

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 107.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                      @estimator_reg_deco
                      def neg_loglkh_gauss_norm_sum(exp_values, sim_values, exp_stds, shots):
                          """
                          Likelihood of the experimental values.
                      
                      
                      Severity: Major
                      Found in c3/libraries/estimators.py and 1 other location - About 6 hrs to fix
                      c3/libraries/estimators.py on lines 122..135

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 103.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                      @estimator_reg_deco
                      def neg_loglkh_gauss_norm(exp_values, sim_values, exp_stds, shots):
                          """
                          Likelihood of the experimental values.
                      
                      
                      Severity: Major
                      Found in c3/libraries/estimators.py and 1 other location - About 6 hrs to fix
                      c3/libraries/estimators.py on lines 138..151

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 103.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      File parametermap.py has 426 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      """ParameterMap class"""
                      
                      from typing import List, Dict, Tuple
                      import hjson
                      import copy
                      Severity: Minor
                      Found in c3/parametermap.py - About 6 hrs to fix

                        File tf_utils.py has 420 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        """Various utility functions to speed up tensorflow coding."""
                        
                        import numpy as np
                        import tensorflow as tf
                        from tensorflow.python.client import device_lib
                        Severity: Minor
                        Found in c3/utils/tf_utils.py - About 6 hrs to fix

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

                          def cmaes(x_init, fun=None, fun_grad=None, grad_lookup=None, options={}):
                              """
                              Wrapper for the pycma implementation of CMA-Es. See also:
                          
                              http://cma.gforge.inria.fr/apidocs-pycma/
                          Severity: Minor
                          Found in c3/libraries/algorithms.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

                          Severity
                          Category
                          Status
                          Source
                          Language