Passed
Push — main ( ec3fe3...82dd22 )
by Douglas
02:00
created

mandos.analysis._plot_utils   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A PlotUtils._markers() 0 14 4
A PlotUtils._colors() 0 4 2
1
"""
0 ignored issues
show
Documentation introduced by
Empty module docstring
Loading history...
2
3
"""
4
5
6
class PlotUtils:
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
7
    def _markers(self, df: pd.DataFrame, col: Optional[str]) -> Optional[pd.Series]:
0 ignored issues
show
Coding Style Naming introduced by
Argument name "df" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
Comprehensibility Best Practice introduced by
Undefined variable 'pd'
Loading history...
Comprehensibility Best Practice introduced by
Undefined variable 'Optional'
Loading history...
Comprehensibility Best Practice introduced by
The variable pd does not seem to be defined.
Loading history...
Coding Style introduced by
This method could be written as a function/class method.

If a method does not access any attributes of the class, it could also be implemented as a function or static method. This can help improve readability. For example

class Foo:
    def some_method(self, x, y):
        return x + y;

could be written as

class Foo:
    @classmethod
    def some_method(cls, x, y):
        return x + y;
Loading history...
8
        from matplotlib.markers import MarkerStyle
0 ignored issues
show
introduced by
Import outside toplevel (matplotlib.markers.MarkerStyle)
Loading history...
introduced by
Unable to import 'matplotlib.markers'
Loading history...
9
10
        if col is None:
11
            return None
12
        known = MarkerStyle.markers.keys()
13
        uniques = df[col].unique()
14
        if all((v in known for v in uniques)):
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable v does not seem to be defined.
Loading history...
15
            return df[col]
16
        if len(uniques) > len(known):
17
            logger.error(f"{len(uniques)} unique markers > {len(known)} available. Cycling.")
0 ignored issues
show
Comprehensibility Best Practice introduced by
Undefined variable 'logger'
Loading history...
Comprehensibility Best Practice introduced by
The variable logger does not seem to be defined.
Loading history...
18
        cycler = cycle(known)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable cycle does not seem to be defined.
Loading history...
Comprehensibility Best Practice introduced by
Undefined variable 'cycle'
Loading history...
19
        dct = {k: next(cycler) for k in uniques}
20
        return df[col].map(dct.get)
21
22
    def _colors(df: pd.DataFrame, col: Optional[str]) -> Optional[pd.Series]:
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable pd does not seem to be defined.
Loading history...
Coding Style Best Practice introduced by
Methods should have self as first argument.

It is a widespread convention and generally a good practice to name the first argument of methods self.

class SomeClass:
    def some_method(self):
        # ... do something
Loading history...
Comprehensibility Best Practice introduced by
Undefined variable 'pd'
Loading history...
Comprehensibility Best Practice introduced by
Undefined variable 'Optional'
Loading history...
Coding Style Naming introduced by
Argument name "df" doesn't conform to snake_case naming style ('([^\\W\\dA-Z][^\\WA-Z]2,|_[^\\WA-Z]*|__[^\\WA-Z\\d_][^\\WA-Z]+__)$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
23
        if col is None:
24
            return None
25
        return df[col]
0 ignored issues
show
introduced by
Value 'df' is unsubscriptable
Loading history...
26