q-optimize/c3

View on GitHub

Showing 160 of 330 total issues

Function start_log has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def start_log(self, opt, logdir):
        self.opt_map = opt.pmap.get_opt_map()
        print("create log at", logdir)
        self.writer = tf.summary.create_file_writer(
            logdir=logdir,
Severity: Minor
Found in c3/optimizers/optimizer.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

Avoid too many return statements within this function.
Open

            return (
Severity: Major
Found in c3/libraries/chip.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                return tape.gradient(val, phi_variable)
    Severity: Major
    Found in c3/libraries/chip.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return val * (10 ** (-3 * (len(big_units) - 1))), big_units[-1]
      Severity: Major
      Found in c3/utils/utils.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return grad
        Severity: Major
        Found in c3/libraries/chip.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return sign * (10 ** (tmp % 3)), prefix
          Severity: Major
          Found in c3/utils/utils.py - About 30 mins to fix

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

                def quick_setup(self, cfg, base_dir: str = None) -> None:
                    """
                    Load a quick setup cfg and create all necessary components.
            
                    Parameters
            Severity: Minor
            Found in c3/experiment.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_Frame_Rotation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_Frame_Rotation(self, t_final: np.float64, freqs: dict, framechanges: dict):
                    """
                    Compute the frame rotation needed to align Lab frame and rotating Eigenframes
                    of the qubits.
            
            
            Severity: Minor
            Found in c3/model.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 set_max_excitations has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def set_max_excitations(self, max_excitations) -> None:
                    """
                    Set the maximum number of excitations in the system used for propagation.
                    """
                    if max_excitations:
            Severity: Minor
            Found in c3/model.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 ask_yn has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def ask_yn() -> bool:
                """Ask for y/n user decision in the command line."""
                asking = True
                text = input("(y/n): ")
                if text == "y":
            Severity: Minor
            Found in c3/utils/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 update_Hamiltonians has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def update_Hamiltonians(self):
                    """Recompute the matrix representations of the Hamiltonians."""
                    control_hams = dict()
                    hamiltonians = dict()
                    for key, sub in self.subsystems.items():
            Severity: Minor
            Found in c3/model.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_potential_function has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_potential_function(self, phi_variable, deriv_order=1, phi_sig=0):
                    phi = (
                        (self.params["phi"].get_value() + phi_sig)
                        / self.params["phi_0"].get_value()
                        * 2
            Severity: Minor
            Found in c3/libraries/chip.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 fromdict has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def fromdict(self, cfg: dict) -> None:
                    """
                    Load a file and parse it to create a Model object.
            
                    Parameters
            Severity: Minor
            Found in c3/model.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_potential_function has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_potential_function(
                    self, phi_variable, deriv_order=1, phi_sig=0
                ) -> tf.float64:
                    if phi_sig != 0:
                        raise NotImplementedError()
            Severity: Minor
            Found in c3/libraries/chip.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_minimum_phi_var has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_minimum_phi_var(self, init_phi_variable: tf.float64 = 0, phi_sig=0):
                    # TODO maybe improve to analytical funciton here
                    # TODO do not reevaluate if not necessary
                    phi_0 = self.params["phi_0"].get_value()
                    initial_pot_eval = self.get_potential_function(0.0, 0)
            Severity: Minor
            Found in c3/libraries/chip.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_noise has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_noise(self, sig):
                    noise_amp = self.params["noise_amp"].get_value().numpy()
                    bfl_num = int(self.params["bfl_num"].get_value().numpy())
                    noise = []
                    bfls = 2 * np.random.randint(2, size=bfl_num) - 1
            Severity: Minor
            Found in c3/generator/devices.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 set_init_state has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def set_init_state(self, state):
                    if self.lindbladian and state.shape[0] != state.shape[1]:
                        if state.shape[0] == self.tot_dim:
                            self.init_state = tf_utils.tf_state_to_dm(state)
                        elif state.shape[0] == self.tot_dim**2:
            Severity: Minor
            Found in c3/model.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 Hs_of_t has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def Hs_of_t(self, signal, interpolate_res=2):
                    """
                    Generate a list of Hamiltonians for each time step of interpolated signal for Runge-Kutta Methods.
            
                    Args:
            Severity: Minor
            Found in c3/model.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 slepian_fourier has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def slepian_fourier(t, params):
                """
                ----
                """
                t_final = tf.cast(params["t_final"].get_value(), tf.float64)
            Severity: Minor
            Found in c3/libraries/envelopes.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 __initialize_parameters has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def __initialize_parameters(self) -> None:
                    par_lens = {}
                    pars = {}
                    par_ids_model = []
                    for comp in self.__components.values():
            Severity: Minor
            Found in c3/parametermap.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

            Severity
            Category
            Status
            Source
            Language