q-optimize/c3

View on GitHub

Showing 303 of 330 total issues

Function goal_run_with_grad has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def goal_run_with_grad(self, current_params):
        """
        Same as goal_run but with gradient. Very resource intensive. Unoptimized at the
        moment.
        """
Severity: Minor
Found in c3/optimizers/modellearning.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 goal_run has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def goal_run(self, current_params: tf.constant) -> tf.float64:
        """
        Evaluate the figure of merit for the current model parameters.

        Parameters
Severity: Minor
Found in c3/optimizers/modellearning.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 __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(
Severity: Major
Found in c3/optimizers/calibration.py - About 1 hr to fix

    Function str_parameters has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def str_parameters(
            self,
            opt_map: Union[List[List[Tuple[str]]], List[List[str]]] = None,
            human=False,
        ) -> str:
    Severity: Minor
    Found in c3/parametermap.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 check_limits has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_limits(self, opt_map):
            """
            Check if all elements of equal ids have the same limits. This has to be checked against if setting values optimizer friendly.
    
            Parameters
    Severity: Minor
    Found in c3/parametermap.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 eng_num has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def eng_num(val: float) -> Tuple[float, str]:
        """Convert a number to engineering notation by returning number and prefix."""
        if np.array(val).size > 1:
            return np.array(val), ""
        if np.isnan(val):
    Severity: Minor
    Found in c3/utils/utils.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

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

        ry90p.comps["d1"]["gauss"].params["xy_angle"].set_value(0.5 * np.pi)
    Severity: Major
    Found in examples/single_qubit_experiment.py and 3 other locations - About 1 hr to fix
    examples/single_qubit_blackbox_exp.py on lines 175..175
    examples/single_qubit_blackbox_exp.py on lines 177..177
    examples/single_qubit_experiment.py on lines 163..163

    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 39.

    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

    Function log_parameters has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def log_parameters(self, evaluation, optim_status):
            if self.store_better_iterations_only:
                if optim_status["goal"] > self.best_iteration:
                    return
                else:
    Severity: Minor
    Found in c3/optimizers/optimizer.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

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

        ry90m.comps["d1"]["gauss"].params["xy_angle"].set_value(1.5 * np.pi)
    Severity: Major
    Found in examples/single_qubit_experiment.py and 3 other locations - About 1 hr to fix
    examples/single_qubit_blackbox_exp.py on lines 175..175
    examples/single_qubit_blackbox_exp.py on lines 177..177
    examples/single_qubit_experiment.py on lines 161..161

    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 39.

    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 3 locations. Consider refactoring.
    Open

        offset = tf.exp(-(t_final**2) / (8 * sigma**2))
    Severity: Major
    Found in c3/libraries/envelopes.py and 2 other locations - About 1 hr to fix
    c3/libraries/envelopes.py on lines 528..528
    c3/libraries/envelopes.py on lines 553..553

    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 39.

    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 3 locations. Consider refactoring.
    Open

        offset = tf.exp(-(t_final**2) / (8 * sigma**2))
    Severity: Major
    Found in c3/libraries/envelopes.py and 2 other locations - About 1 hr to fix
    c3/libraries/envelopes.py on lines 391..391
    c3/libraries/envelopes.py on lines 528..528

    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 39.

    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 3 locations. Consider refactoring.
    Open

        offset = tf.exp(-(t_final**2) / (8 * sigma**2))
    Severity: Major
    Found in c3/libraries/envelopes.py and 2 other locations - About 1 hr to fix
    c3/libraries/envelopes.py on lines 391..391
    c3/libraries/envelopes.py on lines 553..553

    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 39.

    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

    Function RB has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def RB(
    Severity: Major
    Found in c3/libraries/fidelities.py - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

          if isinstance(data, dict):
              return {str(k): jsonify_list(v) for k, v in data.items()}
          elif isinstance(data, list):
              return [jsonify_list(v) for v in data]
          elif isinstance(data, tuple):
      Severity: Major
      Found in c3/c3objs.py - About 1 hr to fix

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

            def __init__(
                self, value, unit="undefined", min_val=None, max_val=None, symbol=r"\alpha"
            ):
                pref = 1.0
                value = np.array(value)
        Severity: Minor
        Found in c3/c3objs.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 get_Lindbladian has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_Lindbladian(self, dims):
                """
                Compute the Lindbladian, based on relaxation, dephasing constants and finite
                temperature.
        
        
        Severity: Minor
        Found in c3/libraries/chip.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 grid2D has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        def grid2D(x_init, fun=None, fun_grad=None, grad_lookup=None, options={}):
            """
            Two dimensional scan of the function values around the initial point.
        
            Parameters
        Severity: Minor
        Found in c3/libraries/algorithms.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 initialise has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialise(self, drift_ham, lindbladian=False, init_temp=None):
                """
                Prepare the initial state of the system. At the moment finite temperature requires open system dynamics.
        
                Parameters
        Severity: Minor
        Found in c3/libraries/tasks.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

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

            shape = tf.reshape(
                tfp.math.interp_regular_1d_grid(
                    t_interp,
                    t_bin_start,
                    t_bin_end,
        Severity: Minor
        Found in c3/libraries/envelopes.py and 1 other location - About 55 mins to fix
        c3/libraries/envelopes.py on lines 87..96

        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 37.

        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

            shape = tf.reshape(
                tfp.math.interp_regular_1d_grid(
                    t_interp,
                    t_bin_start,
                    t_bin_end,
        Severity: Minor
        Found in c3/libraries/envelopes.py and 1 other location - About 55 mins to fix
        c3/libraries/envelopes.py on lines 56..65

        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 37.

        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

        Severity
        Category
        Status
        Source
        Language