bjmorgan/lattice_mc

View on GitHub

Showing 24 of 24 total issues

File lattice.py has 401 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import numpy as np
import random
import itertools
import sys
 
 
Severity: Minor
Found in lattice_mc/lattice.py - About 5 hrs to fix

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

    r = np.array( [ i * sqrt(3) * spacing + sqrt(3)/2 * spacing, ( j * 3 + 1.5 ) * spacing, 0.0 ] )
    Severity: Major
    Found in lattice_mc/init_lattice.py and 1 other location - About 3 hrs to fix
    lattice_mc/init_lattice.py on lines 72..72

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

    r = np.array( [ i * sqrt(3) * spacing + sqrt(3)/2 * spacing, ( j * 3 + 0.5 ) * spacing, 0.0 ] )
    Severity: Major
    Found in lattice_mc/init_lattice.py and 1 other location - About 3 hrs to fix
    lattice_mc/init_lattice.py on lines 78..78

    File simulation.py has 270 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from lattice_mc import init_lattice, species, lookup_table
     
    class Simulation:
    """
    Simulation class
    Severity: Minor
    Found in lattice_mc/simulation.py - About 2 hrs to fix

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

      neighbours = [ grid[ i, j, 1 ],
      grid[ i, j, 3 ],
      np.roll( grid, -1, axis=0 )[ i, j, 3 ] ]
      Severity: Major
      Found in lattice_mc/init_lattice.py and 1 other location - About 2 hrs to fix
      lattice_mc/init_lattice.py on lines 73..75

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

      neighbours = [ grid[ i, j, 0 ],
      grid[ i, j, 2 ],
      np.roll( grid, -1, axis=0 )[ i, j, 0 ] ]
      Severity: Major
      Found in lattice_mc/init_lattice.py and 1 other location - About 2 hrs to fix
      lattice_mc/init_lattice.py on lines 79..81

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

      def potential_jumps( self ):
      """
      All nearest-neighbour jumps not blocked by volume exclusion
      (i.e. from occupied to neighbouring unoccupied sites).
       
       
      Severity: Minor
      Found in lattice_mc/lattice.py - About 1 hr to fix

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

      @property
      def old_tracer_correlation( self ):
      """
      Deprecated tracer correlation factor for this simulation.
      Severity: Major
      Found in lattice_mc/simulation.py and 1 other location - About 1 hr to fix
      lattice_mc/simulation.py on lines 235..255

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

      along_y = any( [ s2 in s1.p_neighbours for s1 in edges[2] for s2 in edges[3] ] )
      Severity: Major
      Found in lattice_mc/cluster.py and 2 other locations - About 1 hr to fix
      lattice_mc/cluster.py on lines 96..96
      lattice_mc/cluster.py on lines 98..98

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

      @property
      def old_collective_correlation( self ):
      """
      Returns the collective correlation factor, f_I
       
       
      Severity: Major
      Found in lattice_mc/simulation.py and 1 other location - About 1 hr to fix
      lattice_mc/simulation.py on lines 181..201

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

      along_x = any( [ s2 in s1.p_neighbours for s1 in edges[0] for s2 in edges[1] ] )
      Severity: Major
      Found in lattice_mc/cluster.py and 2 other locations - About 1 hr to fix
      lattice_mc/cluster.py on lines 97..97
      lattice_mc/cluster.py on lines 98..98

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

      along_z = any( [ s2 in s1.p_neighbours for s1 in edges[4] for s2 in edges[5] ] )
      Severity: Major
      Found in lattice_mc/cluster.py and 2 other locations - About 1 hr to fix
      lattice_mc/cluster.py on lines 96..96
      lattice_mc/cluster.py on lines 97..97

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

      def connected_sites( self, site_labels=None ):
      """
      Searches the lattice to find sets of sites that are contiguously neighbouring.
      Mutually exclusive sets of contiguous sites are returned as Cluster objects.
       
       
      Severity: Minor
      Found in lattice_mc/lattice.py - About 1 hr to fix

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

      def run( self, for_time=None ):
      """
      Run the simulation.
       
      Args:
      Severity: Minor
      Found in lattice_mc/simulation.py - About 1 hr to fix

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

      def generate_nearest_neighbour_lookup_table( self ):
      """
      Construct a look-up table of relative jump probabilities for a nearest-neighbour interaction Hamiltonian.
       
      Args:
      Severity: Minor
      Found in lattice_mc/lookup_table.py - About 1 hr to fix

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

      def enforce_periodic_boundary_conditions( self ):
      """
      Ensure that all lattice sites are within the central periodic image of the simulation cell.
      Sites that are outside the central simulation cell are mapped back into this cell.
      Severity: Minor
      Found in lattice_mc/lattice.py - About 55 mins to fix

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

      sites.append( lattice_site.Site( grid[ i, j, 3 ], r, neighbours, 0.0, site_labels[3] ) )
      Severity: Major
      Found in lattice_mc/init_lattice.py and 3 other locations - About 45 mins to fix
      lattice_mc/init_lattice.py on lines 70..70
      lattice_mc/init_lattice.py on lines 76..76
      lattice_mc/init_lattice.py on lines 82..82

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

      sites.append( lattice_site.Site( grid[ i, j, 2 ], r, neighbours, 0.0, site_labels[2] ) )
      Severity: Major
      Found in lattice_mc/init_lattice.py and 3 other locations - About 45 mins to fix
      lattice_mc/init_lattice.py on lines 70..70
      lattice_mc/init_lattice.py on lines 76..76
      lattice_mc/init_lattice.py on lines 88..88

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

      def __init__( self, number, coordinates, neighbours, energy, label, cn_energies=None ):
      Severity: Minor
      Found in lattice_mc/lattice_site.py - About 45 mins to fix

        Function connected_site_pairs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def connected_site_pairs( self ):
        """
        Returns a dictionary of all connections between pair of sites (by site label).
        e.g. for a linear lattice A-B-C will return::
        Severity: Minor
        Found in lattice_mc/lattice.py - About 45 mins to fix
        Severity
        Category
        Status
        Source
        Language