phydev/trajpy

View on GitHub

Showing 332 of 369 total issues

File trajpy.py has 414 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import numpy as np
from scipy.stats import linregress
import trajpy.auxiliar_functions as aux
from typing import Union, List, Dict, Tuple
import warnings
Severity: Minor
Found in trajpy/trajpy.py - About 5 hrs to fix

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

        def compute_selected(self) -> None:
            '''
                compute the selected features
            '''
            
    Severity: Minor
    Found in trajpy/gui.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 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def __init__(self, trajectory: np.ndarray=np.zeros((1, 2)), box_length: int = None, **params) -> None:
            """
            Initialization function that can be left blank for using staticmethods.
            It can be initialized with an array with shape (N, dim)
            where dim is the number of spatial dimensions plus the time component.
    Severity: Minor
    Found in trajpy/trajpy.py - About 1 hr to fix

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

      def normal_diffusion(n_steps: int, n_samples: int, dx: float, y0: float, D: float, dt: float) -> Tuple[np.ndarray, np.ndarray]:
          """
          Generates an ensemble of normal diffusion trajectories.
      
          :param n_steps: total steps
      Severity: Minor
      Found in trajpy/traj_generator.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 confined_diffusion has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def confined_diffusion(radius: float, n_steps: int, n_samples: int, dx: float, y0: float, D: float, dt: float) -> Tuple[np.ndarray, np.ndarray]:
          """
          Generates trajectories under confinement.
      
          :param radius: confinement radius
      Severity: Minor
      Found in trajpy/traj_generator.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

      Line too long (94 > 79 characters)
      Open

          keywords=['trajectory quantification', 'feature engineering', 'diffusion classification'],
      Severity: Minor
      Found in setup.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (106 > 79 characters)
      Open

              p(r, t) = \\frac{1}{\\sqrt{ 4 \\pi D t}} \\exp{  \\left( \\frac{r^2}{4Dt} \\right)} \\right) \\, .
      Severity: Minor
      Found in trajpy/auxiliar_functions.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Whitespace before '('
      Open

      def unfold (r_old: np.ndarray, r: np.ndarray, box: Union[float, np.ndarray]) -> np.ndarray:
      Severity: Minor
      Found in trajpy/auxiliar_functions.py by pep8

      Avoid extraneous whitespace.

      Avoid extraneous whitespace in the following situations:
      - before the open parenthesis that starts the argument list of a
        function call.
      - before the open parenthesis that starts an indexing or slicing.
      
      Okay: spam(1)
      E211: spam (1)
      
      Okay: dict['key'] = list[index]
      E211: dict ['key'] = list[index]
      E211: dict['key'] = list [index]

      Block comment should start with '# '
      Open

              #self.panel.pack(side = "top", fill = "both", expand = "no")
      Severity: Minor
      Found in trajpy/gui.py by pep8

      Separate inline comments by at least two spaces.

      An inline comment is a comment on the same line as a statement.
      Inline comments should be separated by at least two spaces from the
      statement. They should start with a # and a single space.
      
      Each line of a block comment starts with a # and a single space
      (unless it is indented text inside the comment).
      
      Okay: x = x + 1  # Increment x
      Okay: x = x + 1    # Increment x
      Okay: # Block comment
      E261: x = x + 1 # Increment x
      E262: x = x + 1  #Increment x
      E262: x = x + 1  #  Increment x
      E265: #Block comment
      E266: ### Block comment

      Line too long (91 > 79 characters)
      Open

              self.author = tk.Label(self.newWindow, text="Developed by Maurício Moreira-Soares")
      Severity: Minor
      Found in trajpy/gui.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Line too long (97 > 79 characters)
      Open

                  self.feats_[button].configure(command=partial(self.select_feat, self.feats_[button]))
      Severity: Minor
      Found in trajpy/gui.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.

      Missing whitespace around operator
      Open

              if kind=="file":
      Severity: Minor
      Found in trajpy/gui.py by pep8

      Surround operators with a single space on either side.

      - Always surround these binary operators with a single space on
        either side: assignment (=), augmented assignment (+=, -= etc.),
        comparisons (==, <, >, !=, <=, >=, in, not in, is, is not),
        Booleans (and, or, not).
      
      - If operators with different priorities are used, consider adding
        whitespace around the operators with the lowest priorities.
      
      Okay: i = i + 1
      Okay: submitted += 1
      Okay: x = x * 2 - 1
      Okay: hypot2 = x * x + y * y
      Okay: c = (a + b) * (a - b)
      Okay: foo(bar, key='word', *args, **kwargs)
      Okay: alpha[:-i]
      
      E225: i=i+1
      E225: submitted +=1
      E225: x = x /2 - 1
      E225: z = x **y
      E225: z = 1and 1
      E226: c = (a+b) * (a-b)
      E226: hypot2 = x*x + y*y
      E227: c = a|b
      E228: msg = fmt%(errno, errmsg)

      Missing whitespace after ','
      Open

                      self.r.diffusivity = self.r.green_kubo_(self.r.velocity, self.r._t,self.r.vacf)
      Severity: Minor
      Found in trajpy/gui.py by pep8

      Each comma, semicolon or colon should be followed by whitespace.

      Okay: [a, b]
      Okay: (3,)
      Okay: a[1:4]
      Okay: a[:4]
      Okay: a[1:]
      Okay: a[1:4:2]
      E231: ['a','b']
      E231: foo(bar,baz)
      E231: [{'a':'b'}]

      Continuation line over-indented for visual indent
      Open

                                                          title='Please select a folder')
      Severity: Minor
      Found in trajpy/gui.py by pep8

      Continuation lines indentation.

      Continuation lines should align wrapped elements either vertically
      using Python's implicit line joining inside parentheses, brackets
      and braces, or using a hanging indent.
      
      When using a hanging indent these considerations should be applied:
      - there should be no arguments on the first line, and
      - further indentation should be used to clearly distinguish itself
        as a continuation line.
      
      Okay: a = (\n)
      E123: a = (\n    )
      
      Okay: a = (\n    42)
      E121: a = (\n   42)
      E122: a = (\n42)
      E123: a = (\n    42\n    )
      E124: a = (24,\n     42\n)
      E125: if (\n    b):\n    pass
      E126: a = (\n        42)
      E127: a = (24,\n      42)
      E128: a = (24,\n    42)
      E129: if (a or\n    b):\n    pass
      E131: a = (\n    42\n 24)

      Indentation is not a multiple of 4
      Open

                         self.selected_features.append('Diffusivity')
      Severity: Minor
      Found in trajpy/gui.py by pep8

      Use indent_size (PEP8 says 4) spaces per indentation level.

      For really old code that you don't want to mess up, you can continue
      to use 8-space tabs.
      
      Okay: a = 1
      Okay: if a == 0:\n    a = 1
      E111:   a = 1
      E114:   # a = 1
      
      Okay: for item in items:\n    pass
      E112: for item in items:\npass
      E115: for item in items:\n# Hi\n    pass
      
      Okay: a = 1\nb = 2
      E113: a = 1\n    b = 2
      E116: a = 1\n    # b = 2

      Too many blank lines (4)
      Open

      if __name__ == '__main__':
      Severity: Minor
      Found in trajpy/gui.py by pep8

      Separate top-level function and class definitions with two blank lines.

      Method definitions inside a class are separated by a single blank
      line.
      
      Extra blank lines may be used (sparingly) to separate groups of
      related functions.  Blank lines may be omitted between a bunch of
      related one-liners (e.g. a set of dummy implementations).
      
      Use blank lines in functions, sparingly, to indicate logical
      sections.
      
      Okay: def a():\n    pass\n\n\ndef b():\n    pass
      Okay: def a():\n    pass\n\n\nasync def b():\n    pass
      Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
      Okay: default = 1\nfoo = 1
      Okay: classify = 1\nfoo = 1
      
      E301: class Foo:\n    b = 0\n    def bar():\n        pass
      E302: def a():\n    pass\n\ndef b(n):\n    pass
      E302: def a():\n    pass\n\nasync def b(n):\n    pass
      E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
      E303: def a():\n\n\n\n    pass
      E304: @decorator\n\ndef a():\n    pass
      E305: def a():\n    pass\na()
      E306: def a():\n    def b():\n        pass\n    def c():\n        pass

      Blank line contains whitespace
      Open

                  
      Severity: Minor
      Found in trajpy/traj_generator.py by pep8

      Trailing whitespace is superfluous.

      The warning returned varies on whether the line itself is blank,
      for easier filtering for those who want to indent their blank lines.
      
      Okay: spam(1)\n#
      W291: spam(1) \n#
      W293: class Foo(object):\n    \n    bang = 12

      Blank line contains whitespace
      Open

          
      Severity: Minor
      Found in trajpy/auxiliar_functions.py by pep8

      Trailing whitespace is superfluous.

      The warning returned varies on whether the line itself is blank,
      for easier filtering for those who want to indent their blank lines.
      
      Okay: spam(1)\n#
      W291: spam(1) \n#
      W293: class Foo(object):\n    \n    bang = 12

      Trailing whitespace
      Open

              # retrieving column names to assure consistency 
      Severity: Minor
      Found in trajpy/auxiliar_functions.py by pep8

      Trailing whitespace is superfluous.

      The warning returned varies on whether the line itself is blank,
      for easier filtering for those who want to indent their blank lines.
      
      Okay: spam(1)\n#
      W291: spam(1) \n#
      W293: class Foo(object):\n    \n    bang = 12

      Line too long (80 > 79 characters)
      Open

              self.features = ['Anomalous Exponent', 'MSD Ratio', 'Fractal dimension',
      Severity: Minor
      Found in trajpy/gui.py by pep8

      Limit all lines to a maximum of 79 characters.

      There are still many devices around that are limited to 80 character
      lines; plus, limiting windows to 80 characters makes it possible to
      have several windows side-by-side.  The default wrapping on such
      devices looks ugly.  Therefore, please limit all lines to a maximum
      of 79 characters. For flowing long blocks of text (docstrings or
      comments), limiting the length to 72 characters is recommended.
      
      Reports error E501.
      Severity
      Category
      Status
      Source
      Language