WenjieDu/PyPOTS

View on GitHub
pypots/nn/modules/fedformer/layers.py

Summary

Maintainability
F
4 days
Test Coverage

File layers.py has 711 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""

"""

# Created by Wenjie Du <wenjay.du@gmail.com>
Severity: Major
Found in pypots/nn/modules/fedformer/layers.py - About 1 day to fix

    Function get_phi_psi has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_phi_psi(k, base):
        x = Symbol("x")
        phi_coeff = np.zeros((k, k))
        phi_2x_coeff = np.zeros((k, k))
        if base == "legendre":
    Severity: Minor
    Found in pypots/nn/modules/fedformer/layers.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 __init__ has 14 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Major
    Found in pypots/nn/modules/fedformer/layers.py - About 1 hr to fix

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

      def get_filter(base, k):
          def psi(psi1, psi2, i, inp):
              mask = (inp <= 0.5) * 1.0
              return psi1[i](inp) * mask + psi2[i](inp) * (1 - mask)
      
      
      Severity: Minor
      Found in pypots/nn/modules/fedformer/layers.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 forward has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def forward(
              self,
              q: torch.Tensor,
              k: torch.Tensor,
              v: torch.Tensor,
      Severity: Minor
      Found in pypots/nn/modules/fedformer/layers.py - About 1 hr to fix

        Function forward has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def forward(
                self,
                q: torch.Tensor,
                k: torch.Tensor,
                v: torch.Tensor,
        Severity: Minor
        Found in pypots/nn/modules/fedformer/layers.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 pypots/nn/modules/fedformer/layers.py - About 1 hr to fix

          Function __init__ has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def __init__(
                  self,
                  in_channels,
                  out_channels,
                  seq_len_q,
          Severity: Minor
          Found in pypots/nn/modules/fedformer/layers.py - About 1 hr to fix

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

                def __init__(
            Severity: Major
            Found in pypots/nn/modules/fedformer/layers.py - About 1 hr to fix

              Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self, k=3, alpha=64, L=0, c=1, base="legendre", initializer=None, **kwargs):
              Severity: Major
              Found in pypots/nn/modules/fedformer/layers.py - About 50 mins to fix

                Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def __init__(
                Severity: Major
                Found in pypots/nn/modules/fedformer/layers.py - About 50 mins to fix

                  Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def __init__(self, k, alpha, c=1, nl=1, initializer=None, **kwargs):
                  Severity: Minor
                  Found in pypots/nn/modules/fedformer/layers.py - About 45 mins to fix

                    Function forward has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def forward(
                    Severity: Minor
                    Found in pypots/nn/modules/fedformer/layers.py - About 35 mins to fix

                      Function forward has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def forward(
                      Severity: Minor
                      Found in pypots/nn/modules/fedformer/layers.py - About 35 mins to fix

                        Function forward has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def forward(
                        Severity: Minor
                        Found in pypots/nn/modules/fedformer/layers.py - About 35 mins to fix

                          Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              def __init__(self, in_channels, out_channels, seq_len, modes=0, mode_select_method="random"):
                          Severity: Minor
                          Found in pypots/nn/modules/fedformer/layers.py - About 35 mins to fix

                            Function forward has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                def forward(
                            Severity: Minor
                            Found in pypots/nn/modules/fedformer/layers.py - About 35 mins to fix

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

                                  def forward(
                                      self,
                                      q: torch.Tensor,
                                      k: torch.Tensor,
                                      v: torch.Tensor,
                              Severity: Minor
                              Found in pypots/nn/modules/fedformer/layers.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 forward has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def forward(self, q, k, v, mask):
                                      B, L, E, H = q.shape
                              
                                      xq = q.permute(0, 3, 2, 1)  # size = [B, H, E, L] torch.Size([3, 8, 64, 512])
                                      xk = k.permute(0, 3, 2, 1)
                              Severity: Minor
                              Found in pypots/nn/modules/fedformer/layers.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