Skip to content

Commit

Permalink
add __slots__ to all classes
Browse files Browse the repository at this point in the history
  • Loading branch information
philopon committed Jun 5, 2016
1 parent f6b5af8 commit c835ff4
Show file tree
Hide file tree
Showing 49 changed files with 181 additions and 138 deletions.
4 changes: 4 additions & 0 deletions mordred/ABCIndex.py
Expand Up @@ -13,6 +13,8 @@


class ABCIndexBase(Descriptor):
__slots__ = ()

@classmethod
def preset(cls):
yield cls()
Expand All @@ -31,6 +33,7 @@ def __str__(self):
class ABCIndex(ABCIndexBase):
r"""atom-bond connectivity indez descriptor.
"""
__slots__ = ()

@staticmethod
def _each_bond(bond):
Expand All @@ -51,6 +54,7 @@ def calculate(self):
class ABCGGIndex(ABCIndexBase):
r"""Graovac-Ghorbani atom-bond connectivity index descriptor.
"""
__slots__ = ()

def dependencies(self):
return {'D': DistanceMatrix(self.explicit_hydrogens)}
Expand Down
2 changes: 2 additions & 0 deletions mordred/AcidBase.py
Expand Up @@ -9,6 +9,8 @@


class SmartsCountBase(Descriptor):
__slots__ = '_mol',

@classmethod
def preset(cls):
yield cls()
Expand Down
4 changes: 1 addition & 3 deletions mordred/AdjacencyMatrix.py
Expand Up @@ -12,7 +12,7 @@ class AdjacencyMatrix(Descriptor):
:type type: :py:class:`str`
:param type: :ref:`matrix_aggregating_methods`
"""

__slots__ = ('_type',)
explicit_hydrogens = False

@classmethod
Expand All @@ -22,8 +22,6 @@ def preset(cls):
def __str__(self):
return '{}_A'.format(self._type.__name__)

__slots__ = ('_type',)

def as_key(self):
return self.__class__, (self._type,)

Expand Down
6 changes: 2 additions & 4 deletions mordred/Aromatic.py
Expand Up @@ -7,6 +7,8 @@


class AromaticBase(Descriptor):
__slots__ = ()

@classmethod
def preset(cls):
yield cls()
Expand All @@ -22,9 +24,7 @@ def as_key(self):

class AromaticAtomsCount(AromaticBase):
r"""aromatic atoms count descriptor."""

__slots__ = ()

_name = 'nAromAtom'

def calculate(self):
Expand All @@ -37,9 +37,7 @@ def calculate(self):

class AromaticBondsCount(AromaticBase):
r"""aromatic bonds count descriptor."""

__slots__ = ()

_name = 'nAromBond'

def calculate(self):
Expand Down
3 changes: 1 addition & 2 deletions mordred/AtomCount.py
Expand Up @@ -22,6 +22,7 @@ class AtomCount(Descriptor):
* 'X' - all halogen
* element symbol
"""
__slots__ = ('_type',)

@classmethod
def preset(cls):
Expand All @@ -38,8 +39,6 @@ def explicit_hydrogens(self):
def __str__(self):
return 'n' + self._type

__slots__ = ('_type',)

def as_key(self):
return self.__class__, (self._type,)

Expand Down
23 changes: 14 additions & 9 deletions mordred/Autocorrelation.py
Expand Up @@ -9,6 +9,7 @@


class AutocorrelationBase(Descriptor):
__slots__ = '_prop', '_order'
explicit_hydrogens = True

def __str__(self):
Expand Down Expand Up @@ -57,6 +58,8 @@ def _AATSC(self):


class AutocorrelationProp(AutocorrelationBase):
__slots__ = ()

def as_key(self):
return self.__class__, (self._prop,)

Expand All @@ -67,6 +70,8 @@ def __init__(self, prop):


class AutocorrelationOrder(AutocorrelationBase):
__slots__ = ()

def _prop(self):
pass

Expand All @@ -80,7 +85,7 @@ def __init__(self, order):


class CAVec(AutocorrelationProp):
__slots__ = ('_prop',)
__slots__ = ()
_order = 0

def dependencies(self):
Expand All @@ -91,7 +96,7 @@ def calculate(self, avec):


class GMat(AutocorrelationOrder):
__slots__ = ('_order',)
__slots__ = ()

def dependencies(self):
return {'dmat': DistanceMatrix(self.explicit_hydrogens)}
Expand All @@ -101,7 +106,7 @@ def calculate(self, dmat):


class GSum(AutocorrelationOrder):
__slots__ = ('_order',)
__slots__ = ()

def dependencies(self):
return {'gmat': GMat(self._order)}
Expand Down Expand Up @@ -149,7 +154,7 @@ class ATS(AutocorrelationBase):
:returns: NaN when any properties are NaN
"""

__slots__ = ('_order', '_prop',)
__slots__ = ()

@classmethod
def preset(cls):
Expand Down Expand Up @@ -187,7 +192,7 @@ class AATS(ATS):
* some properties are NaN
"""

__slots__ = ('_order', '_prop',)
__slots__ = ()

def dependencies(self):
return {'ATS': self._ATS, 'gsum': self._gsum}
Expand All @@ -210,7 +215,7 @@ class ATSC(AutocorrelationBase):
:returns: NaN when any properties are NaN
"""

__slots__ = ('_order', '_prop',)
__slots__ = ()

@classmethod
def preset(cls):
Expand Down Expand Up @@ -248,7 +253,7 @@ class AATSC(ATSC):
* any properties are NaN
"""

__slots__ = ('_order', '_prop',)
__slots__ = ()

def dependencies(self):
return {'ATSC': self._ATSC, 'gsum': self._gsum}
Expand Down Expand Up @@ -277,7 +282,7 @@ class MATS(AutocorrelationBase):
* denominator = 0
"""

__slots__ = ('_order', '_prop',)
__slots__ = ()

@classmethod
def preset(cls):
Expand Down Expand Up @@ -311,7 +316,7 @@ class GATS(MATS):
* denominator = 0
"""

__slots__ = ('_order', '_prop',)
__slots__ = ()

def dependencies(self):
return {
Expand Down
4 changes: 2 additions & 2 deletions mordred/BCUT.py
Expand Up @@ -8,6 +8,7 @@


class BCUTBase(Descriptor):
__slots__ = ()
explicit_hydrogens = False
require_connected = True

Expand Down Expand Up @@ -84,6 +85,7 @@ class BCUT(BCUTBase):
* any atomic properties are NaN
* :math:`\left| nth \right| > A`
"""
__slots__ = ('_prop', '_nth',)

@classmethod
def preset(cls):
Expand All @@ -99,8 +101,6 @@ def __str__(self):
else:
return 'BCUT{}-{}h'.format(self._prop, self._nth + 1)

__slots__ = ('_prop', '_nth',)

def as_key(self):
return self.__class__, (self._prop, self._nth)

Expand Down
1 change: 1 addition & 0 deletions mordred/BalabanJ.py
Expand Up @@ -9,6 +9,7 @@

class BalabanJ(Descriptor):
r"""Balaban's J index descriptor(rdkit wrapper)."""
__slots__ = ()

explicit_hydrogens = False

Expand Down
3 changes: 1 addition & 2 deletions mordred/BaryszMatrix.py
Expand Up @@ -64,6 +64,7 @@ class BaryszMatrix(BaryszMatrixBase):
:returns: NaN when any properties are NaN
"""
__slots__ = ('_prop', '_type',)

@classmethod
def preset(cls):
Expand All @@ -72,8 +73,6 @@ def preset(cls):
def __str__(self):
return '{}_Dz{}'.format(self._type.__name__, self._prop)

__slots__ = ('_prop', '_type',)

def as_key(self):
return self.__class__, (self._prop, self._type)

Expand Down
2 changes: 1 addition & 1 deletion mordred/BertzCT.py
Expand Up @@ -9,7 +9,7 @@

class BertzCT(Descriptor):
r"""Bertz CT descriptor(rdkit wrapper)."""

__slots__ = ()
explicit_hydrogens = False

@classmethod
Expand Down
5 changes: 3 additions & 2 deletions mordred/BondCount.py
Expand Up @@ -11,6 +11,8 @@


class BondType(IntEnum):
__slots__ = ()

any = 1
heavy = 2

Expand Down Expand Up @@ -52,6 +54,7 @@ class BondCount(Descriptor):
:type kekulize: bool
:param kekulize: use kekulized structure
"""
__slots__ = ('_type', '_bond_name', '_check_bond', 'kekulize',)

bond_types = tuple(b.name for b in BondType)

Expand All @@ -72,8 +75,6 @@ def __str__(self):
def explicit_hydrogens(self):
return self._type in (BondType.any, BondType.single)

__slots__ = ('_type', '_bond_name', '_check_bond', 'kekulize',)

def as_key(self):
return self.__class__, (self._type, self.kekulize)

Expand Down

0 comments on commit c835ff4

Please sign in to comment.