mfinzi/pristine-ml

View on GitHub

Showing 97 of 97 total issues

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

        return [img.crop((x1, y1, x1 + tw, y1 + th)) for img in imgs]
Severity: Minor
Found in oil/datasetup/joint_transforms.py and 1 other location - About 40 mins to fix
oil/datasetup/joint_transforms.py on lines 108..108

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

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

        return [img.crop((x1, y1, x1 + tw, y1 + th)) for img in imgs]
Severity: Minor
Found in oil/datasetup/joint_transforms.py and 1 other location - About 40 mins to fix
oil/datasetup/joint_transforms.py on lines 57..57

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

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

    def __init__(self, inplanes, planes, groups, stride=1, downsample=None):
Severity: Minor
Found in oil/architectures/img_classifiers/shake_shake.py - About 35 mins to fix

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

        def __init__(self, pad_type='reflect', filt_size=3, stride=2, channels=None, pad_off=0):
    Severity: Minor
    Found in oil/architectures/parts/antialiasing.py - About 35 mins to fix

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

          def __init__(self, perform_trial, config_spec={},
      Severity: Minor
      Found in oil/tuning/study.py - About 35 mins to fix

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

            def __init__(self, inplanes, planes, groups, stride=1, downsample=None):
        Severity: Minor
        Found in oil/architectures/img_classifiers/shake_shake.py - About 35 mins to fix

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

              def __init__(self, pad_type='reflect', filt_size=3, stride=2, channels=None, pad_off=0):
          Severity: Minor
          Found in oil/architectures/parts/antialiasing.py - About 35 mins to fix

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

                def __init__(self, x_dim, y_dim, with_r, *args, **kwargs):
            Severity: Minor
            Found in oil/architectures/parts/CoordConv.py - About 35 mins to fix

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

                  def _wide_layer(self, block, planes, num_blocks, drop_rate, stride):
              Severity: Minor
              Found in oil/architectures/img_classifiers/wide_resnet.py - About 35 mins to fix

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

                    def _make_layer(self, block, planes, groups, blocks, stride=1):
                Severity: Minor
                Found in oil/architectures/img_classifiers/shake_shake.py - About 35 mins to fix

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

                      def __init__(self, *args, cons_weight=.3, advEps=32, entMin=True, **kwargs):
                  Severity: Minor
                  Found in oil/model_trainers/vat.py - About 35 mins to fix

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

                        def _make_layer(self, block, planes, groups, blocks, stride=1):
                    Severity: Minor
                    Found in oil/architectures/img_classifiers/shake_shake.py - About 35 mins to fix

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

                          def __init__(self, in_channels, out_channels, kernel_size, with_r=False, **kwargs):
                      Severity: Minor
                      Found in oil/architectures/parts/CoordConv.py - About 35 mins to fix

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

                            def __init__(self, inplanes,k=16,N=20,drop_rate=0,coords=True):
                        Severity: Minor
                        Found in oil/architectures/parts/blocks.py - About 35 mins to fix

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

                              def __init__(self, log_dir = None,comment='', no_print=False, ema_com=0, **kwargs):
                          Severity: Minor
                          Found in oil/logging/lazyLogger.py - About 35 mins to fix

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

                                def __init__(self, in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1,bias=True, eps=1e-2, n_iter=5, momentum=0.1, mode=4, num_groups=16,debug=False):
                                    # mode 1: remove channel correlation then pixel correlation
                                    # mode 2: only remove pixel correlation
                                    # mode 3: only channel correlation
                                    # mode 4: remove channel correlation and pixel correlation together
                            Severity: Minor
                            Found in oil/architectures/parts/deconv.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 _make_layer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def _make_layer(self, block, planes, groups, blocks, stride=1):
                                    downsample = None
                                    if stride != 1 or self.inplanes != block.out_channels(planes, groups):
                                        if self.downsample_mode == 'basic' or stride == 1:
                                            downsample = nn.Sequential(
                            Severity: Minor
                            Found in oil/architectures/img_classifiers/shake_shake.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 __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def __init__(self, pad_type='reflect', filt_size=3, stride=2, channels=None, pad_off=0):
                                    super(Downsample, self).__init__()
                                    self.filt_size = filt_size
                                    self.pad_off = pad_off
                                    self.pad_sizes = [int(1.*(filt_size-1)/2), int(np.ceil(1.*(filt_size-1)/2)), int(1.*(filt_size-1)/2), int(np.ceil(1.*(filt_size-1)/2))]
                            Severity: Minor
                            Found in oil/architectures/parts/antialiasing.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 __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def __init__(self, pad_type='reflect', filt_size=3, stride=2, channels=None, pad_off=0):
                                    super(Downsample1D, self).__init__()
                                    self.filt_size = filt_size
                                    self.pad_off = pad_off
                                    self.pad_sizes = [int(1. * (filt_size - 1) / 2), int(np.ceil(1. * (filt_size - 1) / 2))]
                            Severity: Minor
                            Found in oil/architectures/parts/antialiasing.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 norm has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def norm(d,keepdim=True):
                                if len(d.shape)==4:
                                    norm = torch.sqrt(1e-6+(d**2).sum(3).sum(2).sum(1))
                                    return norm[:,None,None,None] if keepdim else norm
                                elif len(d.shape)==2:
                            Severity: Minor
                            Found in oil/model_trainers/vat.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

                            Severity
                            Category
                            Status
                            Source
                            Language