Typesetting math: 100%
Chemical Data Processing Library Python API - Version 1.2.3
All Classes Namespaces Functions Variables Pages
Public Member Functions | Properties | List of all members
CDPL.Descr.HammingDistance Class Reference

Functor class for calculating the Hamming Distance [WHAM, CITB] between bitsets. More...

+ Inheritance diagram for CDPL.Descr.HammingDistance:

Public Member Functions

None __init__ ()
 Initializes the HammingDistance instance.
 
None __init__ (HammingDistance func)
 Initializes a copy of the HammingDistance instance func. More...
 
int getObjectID ()
 Returns the numeric identifier (ID) of the wrapped C++ class instance. More...
 
HammingDistance assign (HammingDistance func)
 Replaces the current state of self with a copy of the state of the HammingDistance instance func. More...
 
int __call__ (Util.BitSet bs1, Util.BitSet bs2)
 Calculates the Hamming Distance [WHAM, CITB] between the bitsets bs1 and bs2. More...
 

Properties

 objectID = property(getObjectID)
 

Detailed Description

Functor class for calculating the Hamming Distance [WHAM, CITB] between bitsets.

Constructor & Destructor Documentation

◆ __init__()

None CDPL.Descr.HammingDistance.__init__ ( HammingDistance  func)

Initializes a copy of the HammingDistance instance func.

Parameters
funcThe HammingDistance instance to copy.

Member Function Documentation

◆ getObjectID()

int CDPL.Descr.HammingDistance.getObjectID ( )

Returns the numeric identifier (ID) of the wrapped C++ class instance.

Different Python HammingDistance instances may reference the same underlying C++ class instance. The commonly used Python expression a is not b thus cannot tell reliably whether the two HammingDistance instances a and b reference different C++ objects. The numeric identifier returned by this method allows to correctly implement such an identity test via the simple expression a.getObjectID() != b.getObjectID().

Returns
The numeric ID of the internally referenced C++ class instance.

◆ assign()

HammingDistance CDPL.Descr.HammingDistance.assign ( HammingDistance  func)

Replaces the current state of self with a copy of the state of the HammingDistance instance func.

Parameters
funcThe HammingDistance instance to copy.
Returns
self

◆ __call__()

int CDPL.Descr.HammingDistance.__call__ ( Util.BitSet  bs1,
Util.BitSet  bs2 
)

Calculates the Hamming Distance [WHAM, CITB] between the bitsets bs1 and bs2.

The Hamming Distance D_{ab} is calculated by:

[ D_{ab} = N_a + N_b ]

where N_a is the number of bits that are set in the first bitset but not in the second bitset and N_b is the number of bits that are set in the second bitset but not in the first one.

If the specified bitsets bs1 and bs2 are of different size, missing bits at the end of the smaller bitset are assumed to be zero.

Parameters
bs1The first bitset.
bs2The second bitset.
Returns
The calculated distance.