Issues (942)

skchem/features/physicochemical.py (13 issues)

1
#! /usr/bin/env python
2
#
3
# Copyright (C) 2015-Rich Lewis <[email protected]>
4
# License: 3-clause BSD
5
6 1
"""
7
## skchem.descriptors.physicochemical
8
9
Physicochemical descriptors and associated functions are defined.
10
11
"""
12
13 1
from rdkit.Chem import Descriptors
0 ignored issues
show
The import rdkit.Chem could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
14 1
import pandas as pd
0 ignored issues
show
The import pandas could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
15 1
import numpy as np
0 ignored issues
show
The import numpy could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
16
17 1
from ..base import Transformer, Featurizer
18 1
from ..utils import camel_to_snail
19
20 1
DESCRIPTORS = {camel_to_snail(s): f for (s, f) in Descriptors.descList}
21
22
23 1
class PhysicochemicalFeaturizer(Transformer, Featurizer):
24
25
    """ Physicochemical descriptor generator using RDKit descriptor """
26
27 1
    def __init__(self, features='all', **kwargs):
28
29
        """ Create a physicochemical descriptor generator.
30
31
        Args:
32
            descriptors (list<(str, func)> or 'all'):
33
                Descriptors to calculate, or if 'all', use all descriptors."""
34
35
        super(PhysicochemicalFeaturizer, self).__init__(**kwargs)
36
37
        self.features = features
38
39 1
    @property
40
    def features(self):
0 ignored issues
show
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
41
        return self._features
42
43 1 View Code Duplication
    @features.setter
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
44
    def features(self, features):
0 ignored issues
show
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
45
        if features == 'all':
46
            features = DESCRIPTORS
47
        elif isinstance(features, str):
48
            features = {features: DESCRIPTORS[features]}
49
        elif isinstance(features, list):
50
            features = {feature: DESCRIPTORS[feature] for feature in features}
51
        elif isinstance(features, (dict, pd.Series)):
52
            features = features
53
        else:
54
            raise NotImplementedError('Cannot use features {}'.format(features))
55
56
        self._features = pd.Series(features)
0 ignored issues
show
The attribute _features was defined outside __init__.

It is generally a good practice to initialize all attributes to default values in the __init__ method:

class Foo:
    def __init__(self, x=None):
        self.x = x
Loading history...
57
        self._features.index.name = 'physicochemical_features'
58
59 1
    @property
60
    def name(self):
0 ignored issues
show
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
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...
61
        return 'physchem'
62
63 1
    @property
64
    def columns(self):
65
        return self.features.index
66
67 1
    def _transform_mol(self, mol):
68
        res = []
69
        for (n, f) in self.features.iteritems():
0 ignored issues
show
Coding Style Naming introduced by
The name n does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$).

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...
Coding Style Naming introduced by
The name f does not conform to the variable naming conventions ([a-z_][a-z0-9_]{2,30}$).

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...
The Instance of str does not seem to have a member named iteritems.

This check looks for calls to members that are non-existent. These calls will fail.

The member could have been renamed or removed.

Loading history...
The variable n seems to be unused.
Loading history...
70
            try:
71
                res.append(f(mol))
72
            except ValueError:
73
                return res.append(np.NaN)
74
75
        return np.array(res)
76