mfinzi/LieConv

View on GitHub

Showing 50 of 55 total issues

File datasets.py has 512 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import math
import torch
import torchvision.transforms as transforms
import torch.nn as nn
import torch.nn.functional as F
Severity: Major
Found in lie_conv/datasets.py - About 1 day to fix

    File lieGroups.py has 510 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import torch
    import numpy as np
    from lie_conv.utils import export, Named
    
    @export
    Severity: Major
    Found in lie_conv/lieGroups.py - About 1 day to fix

      File lieConv.py has 322 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """ 
      Note to the Reader:
      
      In order to handle the generic spatial data we process features as a tuple: (coordinates,values,mask)
      with shapes (bs,n,d), (bs,n,c), (bs,n) where bs is batchsize, n is the maximum number of points in the minibatch,
      Severity: Minor
      Found in lie_conv/lieConv.py - About 3 hrs to fix

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

            def __init__(self, chin, ds_frac=1, num_outputs=1, k=1536, nbhd=np.inf,
        Severity: Major
        Found in lie_conv/lieConv.py - About 2 hrs to fix

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

              def __init__(self, data, included_species=None, num_pts=-1, normalize=True, shuffle=True, subtract_thermo=True):
          
                  self.data = data
          
                  if num_pts < 0:
          Severity: Minor
          Found in corm_data/dataset.py - About 2 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 process_xyz_md17 has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          def process_xyz_md17(datafile):
              """
              Read xyz file and return a molecular dict with number of atoms, energy, forces, coordinates and atom-type for the MD-17 dataset.
          
              Parameters
          Severity: Minor
          Found in corm_data/prepare/process.py - About 2 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 makeTrainer has 15 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def makeTrainer(*, dataset=MnistRotDataset, network=ImgLieResnet, num_epochs=100,
          Severity: Major
          Found in examples/train_img.py - About 1 hr to fix

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

                    self.median_stats = {key: (val.median(), torch.median(torch.abs(val - val.median()))) for key, val in self.data.items() 
                                         if type(val) is torch.Tensor and val.dim() == 1 and val.is_floating_point()}
            Severity: Major
            Found in corm_data/dataset.py and 1 other location - About 1 hr to fix
            corm_data/dataset.py on lines 78..79

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

            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

                    self.stats = {key: (val.mean(), val.std()) for key, val in self.data.items() 
                                  if type(val) is torch.Tensor and val.dim() == 1 and val.is_floating_point()}
            Severity: Major
            Found in corm_data/dataset.py and 1 other location - About 1 hr to fix
            corm_data/dataset.py on lines 80..81

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

            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 prepare_dataset has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

            def prepare_dataset(datadir, dataset, subset=None, splits=None, cleanup=True, force_download=False):
                """
                Download and process dataset.
            
                Parameters
            Severity: Minor
            Found in corm_data/prepare/download.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 makeTrainer has 11 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def makeTrainer(*, task='homo', device='cuda', lr=3e-3, bs=75, num_epochs=500,network=MolecLieResNet, 
            Severity: Major
            Found in examples/equivariance_demo.py - About 1 hr to fix

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

                  def __init__(self,chin=1,total_ds=1/64,num_layers=6,group=T(2),fill=1/32,k=256,
              Severity: Major
              Found in lie_conv/lieConv.py - About 1 hr to fix

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

                    def __init__(self,d=2,sys_dim=2,bn=False,num_layers=4,group=T(2),k=384,knn=False,nbhd=100,mean=True,center=True,**kwargs):
                Severity: Major
                Found in lie_conv/dynamicsTrainer.py - About 1 hr to fix

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

                      def __init__(self,d=2,sys_dim=2,bn=False,num_layers=4,group=T(2),k=384,knn=False,nbhd=100,mean=True,**kwargs):
                  Severity: Major
                  Found in lie_conv/dynamicsTrainer.py - About 1 hr to fix

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

                                self.running_var = (
                                    (1 - self.momentum) * self.running_var
                                    + self.momentum * unbias_var.detach())
                    Severity: Major
                    Found in lie_conv/masked_batchnorm.py and 1 other location - About 1 hr to fix
                    lie_conv/masked_batchnorm.py on lines 22..24

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

                    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

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

                                self.running_mean = (
                                    (1 - self.momentum) * self.running_mean
                                    + self.momentum * xmean.detach())
                    Severity: Major
                    Found in lie_conv/masked_batchnorm.py and 1 other location - About 1 hr to fix
                    lie_conv/masked_batchnorm.py on lines 25..27

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

                    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

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

                        for split, data in gdb9_data.items():
                            savedir = join(gdb9dir, split+'.npz')
                            np.savez_compressed(savedir, **data)
                    Severity: Major
                    Found in corm_data/prepare/qm9.py and 1 other location - About 1 hr to fix
                    corm_data/prepare/md17.py on lines 77..79

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

                    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

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

                        for split, data_split in md17_data_split.items():
                            savefile = join(md17dir, split + '.npz')
                            np.savez_compressed(savefile, **data_split)
                    Severity: Major
                    Found in corm_data/prepare/md17.py and 1 other location - About 1 hr to fix
                    corm_data/prepare/qm9.py on lines 59..61

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

                    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 __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def __init__(self,chin,chout,mc_samples=32,xyz_dim=3,ds_frac=1,knn_channels=None,act='swish',bn=False,mean=False):
                    Severity: Major
                    Found in lie_conv/lieConv.py - About 1 hr to fix

                      Function gen_splits_gdb9 has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      def gen_splits_gdb9(gdb9dir, cleanup=True):
                          """
                          Generate GDB9 training/validation/test splits used.
                      
                          First, use the file 'uncharacterized.txt' in the GDB9 figshare to find a
                      Severity: Minor
                      Found in corm_data/prepare/qm9.py - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language