Completed
Push — master ( 2bc047...202252 )
by Rich
01:16
created

skchem.core.Atom   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 42
Duplicated Lines 0 %
Metric Value
dl 0
loc 42
rs 10
wmc 7

4 Methods

Rating   Name   Duplication   Size   Complexity  
A Atom.element() 0 6 1
A Atom.atomic_mass() 0 6 1
A Atom.mass() 0 6 1
A Atom.atomic_number() 0 6 1
1
#! /usr/bin/env python
2
#
3
# Copyright (C) 2007-2009 Rich Lewis <[email protected]>
4
# License: 3-clause BSD
5
6
7
"""
8
skchem.core.atom
9
10
Defining atoms in scikit-chem.
11
"""
12
13
from rdkit import Chem
0 ignored issues
show
Configuration introduced by
The import rdkit 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
from skchem.core import ChemicalObject
15
16
class Atom(Chem.rdchem.Atom, ChemicalObject):
17
18
    """ Object representing an Atom in scikit-chem. """
19
20
    @property
21
    def element(self):
22
23
        """ Get the element of the atom as a string. """
24
25
        return self.GetSymbol()
0 ignored issues
show
Bug introduced by
The Instance of Atom does not seem to have a member named GetSymbol.

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...
26
27
    @property
28
    def atomic_number(self):
29
30
        """ Get the atomic number of the atom as a float. """
31
32
        return self.GetAtomicNum()
0 ignored issues
show
Bug introduced by
The Instance of Atom does not seem to have a member named GetAtomicNum.

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...
33
34
    @property
35
    def mass(self):
36
37
        """ Get the mass of the atom as a float. """
38
39
        return self.GetMass()
0 ignored issues
show
Bug introduced by
The Instance of Atom does not seem to have a member named GetMass.

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...
40
41
    @property
42
    def atomic_mass(self):
43
44
        """ Get the mass of the atom as a float. """
45
46
        return self.mass
47
48
    @property
49
    def props(self):
50
51
        """ Return a dictionary of properties of the atom. """
52
53
        # Some atom properties are inaccessible, but still give values.
54
        #
55
56
        props = {}
57
58
        for prop in self.GetPropNames():
0 ignored issues
show
Bug introduced by
The Instance of Atom does not seem to have a member named GetPropNames.

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...
59
            try:
60
                props[prop] = self.GetProp(prop)
0 ignored issues
show
Bug introduced by
The Instance of Atom does not seem to have a member named GetProp.

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...
61
            except RuntimeError:
62
                pass
63
64
        return props
65
66
    def __repr__(self):
67
68
        return '<{klass} element="{element}" at {address}>'.format(
69
            klass=self.__class__.__name__,
70
            element=self.element,
71
            address=hex(id(self))
72
            )
73
74
    def __str__(self):
75
        return self.element
76