Package CHEM :: Package datatype :: Module finger :: Class Finger
[hide private]
[frames] | no frames]

Class Finger



_object --+
          |
         Finger


This class encapsulates most fingerprint operations.

Blank fingerprint:

>>> print Finger(128)
128.----------------------

Of course, a valid length must be passed:
>>> print Finger(-2394)
Traceback (most recent call last):
    ...
ValueError: FPmk: Len must > 0.


From Finger object:

>>> print ImmutableFinger(Finger('128.fue*3kdfj-J2dkf7Mk1*--'))
128.fue*3kdfj-J2dkf7Mk1*--

From string:

Fingerpints can be generated from fingerprint string consisting of:
1. an integer length
2. a period '.'
3. any number of characters selected from [a-z,A-Z,0-9,-,*]
>>> print Finger('128.fue*3kdfj-J2dkf7Mk1*') 
128.fue*3kdfj-J2dkf7Mk1*--

Extra characters are truncated:
>>> print Finger('128.fue*3kdfj-J2dkf7Mk1*----------343432')
128.fue*3kdfj-J2dkf7Mk1*--

Illegal characters generates an exception.
>>> print Finger('182.*#,$$(Q*')
Traceback (most recent call last):
    ...
ValueError: FPin: error reading fingerprint. Most likely illegal character.


From random:

Fingerprints can be generated from a random number generator:
>>> f=Finger(120,.3)

A valid lenght and density must be used:
>>> f=Finger(-1,12.0)
Traceback (most recent call last):
    ...
ValueError: FPrand: len must > 0 and density must be bewteen 0 and 1 (inclusive).



Instance Methods [hide private]
 
__repr__(self)
 
__init__(self, *args)
__init__(self, Finger f) -> Finger __init__(self, char c) -> Finger __init__(self, int len, double density) -> Finger __init__(self, int len) -> Finger This class encapsulates most fingerprint operations.
 
__str__(*args)
__str__(self, void ?) -> char
 
__len__(self)
* In this module there are a large number of functions.
 
__cmp__(*args)
__cmp__(self, Finger other) -> int
 
__getitem__(*args)
__getitem__(self, int idx) -> int
 
__and__(*args)
__and__(self, Finger o) -> Finger
 
__or__(*args)
__or__(self, Finger o) -> Finger
 
__setitem__(*args)
__setitem__(self, int idx, int v)
 
density(self)
* In this module there are a large number of functions.
 
bitcount(self)
* In this module there are a large number of functions.
 
Bitcount(self)
* In this module there are a large number of functions.
 
__hash__(self)
Once a Fingerprint is created, if it is an ImmutableFinger, it can be hashed:
 
__reduce__(self)
This function implements the __reduce__ method so Finger instances can be pickled and unpickled.
Class Variables [hide private]
  __swig_setmethods__ = {}
  __setattr__ = lambda self, name, value:
  __swig_getmethods__ = {}
  __getattr__ = lambda self, name:
  __swig_destroy__ = _finger.delete_Finger
  __del__ = lambda self:
Method Details [hide private]

__init__(self, *args)
(Constructor)

 

__init__(self, Finger f) -> Finger
__init__(self, char c) -> Finger
__init__(self, int len, double density) -> Finger
__init__(self, int len) -> Finger

This class encapsulates most fingerprint operations.

Blank fingerprint:

>>> print Finger(128)
128.----------------------

Of course, a valid length must be passed:
>>> print Finger(-2394)
Traceback (most recent call last):
    ...
ValueError: FPmk: Len must > 0.


From Finger object:

>>> print ImmutableFinger(Finger('128.fue*3kdfj-J2dkf7Mk1*--'))
128.fue*3kdfj-J2dkf7Mk1*--

From string:

Fingerpints can be generated from fingerprint string consisting of:
1. an integer length
2. a period '.'
3. any number of characters selected from [a-z,A-Z,0-9,-,*]
>>> print Finger('128.fue*3kdfj-J2dkf7Mk1*') 
128.fue*3kdfj-J2dkf7Mk1*--

Extra characters are truncated:
>>> print Finger('128.fue*3kdfj-J2dkf7Mk1*----------343432')
128.fue*3kdfj-J2dkf7Mk1*--

Illegal characters generates an exception.
>>> print Finger('182.*#,$$(Q*')
Traceback (most recent call last):
    ...
ValueError: FPin: error reading fingerprint. Most likely illegal character.


From random:

Fingerprints can be generated from a random number generator:
>>> f=Finger(120,.3)

A valid lenght and density must be used:
>>> f=Finger(-1,12.0)
Traceback (most recent call last):
    ...
ValueError: FPrand: len must > 0 and density must be bewteen 0 and 1 (inclusive).

__str__(*args)
(Informal representation operator)

 

__str__(self, void ?) -> char

* In this module there are a large number of functions. They are partially organized by different * prefixes. * * FP = General purpose functions and functions for operating on standard folded fingerprints. * * FPD = Bit Decoders used to read fingerprints as binary data. This set of functions is used to * by the more complex compression schemes to decode fingerprints encoded by golomb.py. * * And a few definitions of different compressed types of fingerprints. Each of these types has a * special digit (G,S,P, or M) used at times to signal there usage in arguements. For example, * a FPSG???(FINGER *f1, FINGER *f2) would take a Sparse fingerprint for f1 and a Golomb fingerprint * for f2. * * FPG = Golomb Fingerprints encoded as described in golomb.py * FPS = Sparse fingerprints, storing 32-bit integers in system format. * FPP = Modified Elias Gamma MEG-I fingerprints as described in golomb.py. * FPM = Modified Elias Gamma MEG-R fingerprints as described in golomb.py.

Some of these names may seem cryptic. Many of them are renamed much prettier names in prettyfinger.py.

__len__(self)
(Length operator)

 

* In this module there are a large number of functions. They are partially organized by different * prefixes. * * FP = General purpose functions and functions for operating on standard folded fingerprints. * * FPD = Bit Decoders used to read fingerprints as binary data. This set of functions is used to * by the more complex compression schemes to decode fingerprints encoded by golomb.py. * * And a few definitions of different compressed types of fingerprints. Each of these types has a * special digit (G,S,P, or M) used at times to signal there usage in arguements. For example, * a FPSG???(FINGER *f1, FINGER *f2) would take a Sparse fingerprint for f1 and a Golomb fingerprint * for f2. * * FPG = Golomb Fingerprints encoded as described in golomb.py * FPS = Sparse fingerprints, storing 32-bit integers in system format. * FPP = Modified Elias Gamma MEG-I fingerprints as described in golomb.py. * FPM = Modified Elias Gamma MEG-R fingerprints as described in golomb.py.

Some of these names may seem cryptic. Many of them are renamed much prettier names in prettyfinger.py.
Returns:
int

__cmp__(*args)
(Comparison operator)

 

__cmp__(self, Finger other) -> int

* In this module there are a large number of functions. They are partially organized by different * prefixes. * * FP = General purpose functions and functions for operating on standard folded fingerprints. * * FPD = Bit Decoders used to read fingerprints as binary data. This set of functions is used to * by the more complex compression schemes to decode fingerprints encoded by golomb.py. * * And a few definitions of different compressed types of fingerprints. Each of these types has a * special digit (G,S,P, or M) used at times to signal there usage in arguements. For example, * a FPSG???(FINGER *f1, FINGER *f2) would take a Sparse fingerprint for f1 and a Golomb fingerprint * for f2. * * FPG = Golomb Fingerprints encoded as described in golomb.py * FPS = Sparse fingerprints, storing 32-bit integers in system format. * FPP = Modified Elias Gamma MEG-I fingerprints as described in golomb.py. * FPM = Modified Elias Gamma MEG-R fingerprints as described in golomb.py.

Some of these names may seem cryptic. Many of them are renamed much prettier names in prettyfinger.py.

__getitem__(*args)
(Indexing operator)

 

__getitem__(self, int idx) -> int

* In this module there are a large number of functions. They are partially organized by different * prefixes. * * FP = General purpose functions and functions for operating on standard folded fingerprints. * * FPD = Bit Decoders used to read fingerprints as binary data. This set of functions is used to * by the more complex compression schemes to decode fingerprints encoded by golomb.py. * * And a few definitions of different compressed types of fingerprints. Each of these types has a * special digit (G,S,P, or M) used at times to signal there usage in arguements. For example, * a FPSG???(FINGER *f1, FINGER *f2) would take a Sparse fingerprint for f1 and a Golomb fingerprint * for f2. * * FPG = Golomb Fingerprints encoded as described in golomb.py * FPS = Sparse fingerprints, storing 32-bit integers in system format. * FPP = Modified Elias Gamma MEG-I fingerprints as described in golomb.py. * FPM = Modified Elias Gamma MEG-R fingerprints as described in golomb.py.

Some of these names may seem cryptic. Many of them are renamed much prettier names in prettyfinger.py.

__and__(*args)
(And operator)

 

__and__(self, Finger o) -> Finger

* In this module there are a large number of functions. They are partially organized by different * prefixes. * * FP = General purpose functions and functions for operating on standard folded fingerprints. * * FPD = Bit Decoders used to read fingerprints as binary data. This set of functions is used to * by the more complex compression schemes to decode fingerprints encoded by golomb.py. * * And a few definitions of different compressed types of fingerprints. Each of these types has a * special digit (G,S,P, or M) used at times to signal there usage in arguements. For example, * a FPSG???(FINGER *f1, FINGER *f2) would take a Sparse fingerprint for f1 and a Golomb fingerprint * for f2. * * FPG = Golomb Fingerprints encoded as described in golomb.py * FPS = Sparse fingerprints, storing 32-bit integers in system format. * FPP = Modified Elias Gamma MEG-I fingerprints as described in golomb.py. * FPM = Modified Elias Gamma MEG-R fingerprints as described in golomb.py.

Some of these names may seem cryptic. Many of them are renamed much prettier names in prettyfinger.py.

__or__(*args)
(Or operator)

 

__or__(self, Finger o) -> Finger

* In this module there are a large number of functions. They are partially organized by different * prefixes. * * FP = General purpose functions and functions for operating on standard folded fingerprints. * * FPD = Bit Decoders used to read fingerprints as binary data. This set of functions is used to * by the more complex compression schemes to decode fingerprints encoded by golomb.py. * * And a few definitions of different compressed types of fingerprints. Each of these types has a * special digit (G,S,P, or M) used at times to signal there usage in arguements. For example, * a FPSG???(FINGER *f1, FINGER *f2) would take a Sparse fingerprint for f1 and a Golomb fingerprint * for f2. * * FPG = Golomb Fingerprints encoded as described in golomb.py * FPS = Sparse fingerprints, storing 32-bit integers in system format. * FPP = Modified Elias Gamma MEG-I fingerprints as described in golomb.py. * FPM = Modified Elias Gamma MEG-R fingerprints as described in golomb.py.

Some of these names may seem cryptic. Many of them are renamed much prettier names in prettyfinger.py.

__setitem__(*args)
(Index assignment operator)

 

__setitem__(self, int idx, int v)

* In this module there are a large number of functions. They are partially organized by different * prefixes. * * FP = General purpose functions and functions for operating on standard folded fingerprints. * * FPD = Bit Decoders used to read fingerprints as binary data. This set of functions is used to * by the more complex compression schemes to decode fingerprints encoded by golomb.py. * * And a few definitions of different compressed types of fingerprints. Each of these types has a * special digit (G,S,P, or M) used at times to signal there usage in arguements. For example, * a FPSG???(FINGER *f1, FINGER *f2) would take a Sparse fingerprint for f1 and a Golomb fingerprint * for f2. * * FPG = Golomb Fingerprints encoded as described in golomb.py * FPS = Sparse fingerprints, storing 32-bit integers in system format. * FPP = Modified Elias Gamma MEG-I fingerprints as described in golomb.py. * FPM = Modified Elias Gamma MEG-R fingerprints as described in golomb.py.

Some of these names may seem cryptic. Many of them are renamed much prettier names in prettyfinger.py.

density(self)

 

* In this module there are a large number of functions. They are partially organized by different * prefixes. * * FP = General purpose functions and functions for operating on standard folded fingerprints. * * FPD = Bit Decoders used to read fingerprints as binary data. This set of functions is used to * by the more complex compression schemes to decode fingerprints encoded by golomb.py. * * And a few definitions of different compressed types of fingerprints. Each of these types has a * special digit (G,S,P, or M) used at times to signal there usage in arguements. For example, * a FPSG???(FINGER *f1, FINGER *f2) would take a Sparse fingerprint for f1 and a Golomb fingerprint * for f2. * * FPG = Golomb Fingerprints encoded as described in golomb.py * FPS = Sparse fingerprints, storing 32-bit integers in system format. * FPP = Modified Elias Gamma MEG-I fingerprints as described in golomb.py. * FPM = Modified Elias Gamma MEG-R fingerprints as described in golomb.py.

Some of these names may seem cryptic. Many of them are renamed much prettier names in prettyfinger.py.
Returns:
double

bitcount(self)

 

* In this module there are a large number of functions. They are partially organized by different * prefixes. * * FP = General purpose functions and functions for operating on standard folded fingerprints. * * FPD = Bit Decoders used to read fingerprints as binary data. This set of functions is used to * by the more complex compression schemes to decode fingerprints encoded by golomb.py. * * And a few definitions of different compressed types of fingerprints. Each of these types has a * special digit (G,S,P, or M) used at times to signal there usage in arguements. For example, * a FPSG???(FINGER *f1, FINGER *f2) would take a Sparse fingerprint for f1 and a Golomb fingerprint * for f2. * * FPG = Golomb Fingerprints encoded as described in golomb.py * FPS = Sparse fingerprints, storing 32-bit integers in system format. * FPP = Modified Elias Gamma MEG-I fingerprints as described in golomb.py. * FPM = Modified Elias Gamma MEG-R fingerprints as described in golomb.py.

Some of these names may seem cryptic. Many of them are renamed much prettier names in prettyfinger.py.
Returns:
int

Bitcount(self)

 

* In this module there are a large number of functions. They are partially organized by different * prefixes. * * FP = General purpose functions and functions for operating on standard folded fingerprints. * * FPD = Bit Decoders used to read fingerprints as binary data. This set of functions is used to * by the more complex compression schemes to decode fingerprints encoded by golomb.py. * * And a few definitions of different compressed types of fingerprints. Each of these types has a * special digit (G,S,P, or M) used at times to signal there usage in arguements. For example, * a FPSG???(FINGER *f1, FINGER *f2) would take a Sparse fingerprint for f1 and a Golomb fingerprint * for f2. * * FPG = Golomb Fingerprints encoded as described in golomb.py * FPS = Sparse fingerprints, storing 32-bit integers in system format. * FPP = Modified Elias Gamma MEG-I fingerprints as described in golomb.py. * FPM = Modified Elias Gamma MEG-R fingerprints as described in golomb.py.

Some of these names may seem cryptic. Many of them are renamed much prettier names in prettyfinger.py.
Returns:
float

__hash__(self)
(Hashing function)

 
Once a Fingerprint is created, if it is an ImmutableFinger, it can be hashed:
>>> hash(ImmutableFinger('128.12319fj329jewi93j1'))
1186272689
>>> hash(Finger('128.12319fj329jewi93j1'))
Traceback (most recent call last):
    ...
TypeError: This object is mutable and unhashable.

__reduce__(self)

 
This function implements the __reduce__ method so Finger instances can be pickled and unpickled.
>>> import pickle
>>> f1=Finger(128,.3)
>>> f1.id=100
>>> s=pickle.dumps(f1)
>>> f2=pickle.loads(s)
>>> f1==f2
1
>>> f2.id==f1.id
1