~ubuntu-branches/ubuntu/natty/python-cogent/natty

« back to all changes in this revision

Viewing changes to cogent/maths/matrix_exponentiation.py

  • Committer: Bazaar Package Importer
  • Author(s): Steffen Moeller
  • Date: 2010-12-04 22:30:35 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101204223035-j11kinhcrrdgg2p2
Tags: 1.5-1
* Bumped standard to 3.9.1, no changes required.
* New upstream version.
  - major additions to Cookbook
  - added AlleleFreqs attribute to ensembl Variation objects.
  - added getGeneByStableId method to genome objects.
  - added Introns attribute to Transcript objects and an Intron class.
  - added Mann-Whitney test and a Monte-Carlo version
  - exploratory and confirmatory period estimation techniques (suitable for
    symbolic and continuous data)
  - Information theoretic measures (AIC and BIC) added
  - drawing of trees with collapsed nodes
  - progress display indicator support for terminal and GUI apps
  - added parser for illumina HiSeq2000 and GAiix sequence files as 
    cogent.parse.illumina_sequence.MinimalIlluminaSequenceParser.
  - added parser to FASTQ files, one of the output options for illumina's
    workflow, also added cookbook demo.
  - added functionality for parsing of SFF files without the Roche tools in
    cogent.parse.binary_sff
  - thousand fold performance improvement to nmds
  - >10-fold performance improvements to some Table operations

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
# Taylor     instant        very slow
12
12
 
13
13
from cogent.util.modules import importVersionedModule, ExpectedImportError
 
14
import warnings
14
15
import numpy
15
16
Float = numpy.core.numerictypes.sctype2char(float)
16
17
from numpy.linalg import inv as _inv, eig as _eig,\
17
18
                        solve as solve_linear_equations, LinAlgError
18
19
 
19
 
import logging
20
 
LOG = logging.getLogger('cogent.maths.exponentiation')
21
 
 
22
20
__author__ = "Peter Maxwell"
23
21
__copyright__ = "Copyright 2007-2009, The Cogent Project"
24
22
__credits__ = ["Peter Maxwell", "Gavin Huttley", "Zongzhi Liu"]
25
23
__license__ = "GPL"
26
 
__version__ = "1.4.1"
 
24
__version__ = "1.5.0"
27
25
__maintainer__ = "Gavin Huttley"
28
26
__email__ = "gavin.huttley@anu.edu.au"
29
27
__status__ = "Production"
43
41
 
44
42
try:
45
43
    pyrex = importVersionedModule('_matrix_exponentiation', globals(),
46
 
            (1, 2), LOG, "pure Python/NumPy exponentiation")
 
44
            (1, 2), "pure Python/NumPy exponentiation")
47
45
except ExpectedImportError:
48
46
    pyrex = None
49
47
else:
127
125
            trm = numpy.dot(trm, A/float(k))
128
126
            eA += trm
129
127
        if k >= self.q:
130
 
            LOG.warning("Taylor series lengthened from %s to %s" % (self.q, k+1))
 
128
            warnings.warn("Taylor series lengthened from %s to %s" % (self.q, k+1))
131
129
            self.q = k + 1
132
130
        return eA
133
131
    
241
239
 
242
240
def chooseFastExponentiators(Q):
243
241
    ex = _chooseFastExponentiators(Q)
244
 
    LOG.info('Strategy for Q Size %s: PyrexEig:%s PyrexInv:%s PyrexExp:%s'
245
 
        % (
246
 
        Q.shape[0],
247
 
        (ex[0].eigenvectors is not eig),
248
 
        (ex[0].inverse is not inv),
249
 
        (ex[0].exponentiator is not EigenExponentiator)))
 
242
    if False:
 
243
        used_pyrex = [['numpy','pyrex'][u] for u in [
 
244
            (ex[0].eigenvectors is not eig),
 
245
            (ex[0].inverse is not inv),
 
246
            (ex[0].exponentiator is not EigenExponentiator)]]
 
247
        print ('Strategy for Q Size %2s: ' % Q.shape[0] + 
 
248
                'Eig:%s Inv:%s Exp:%s' % tuple(used_pyrex))
250
249
    return ex
251
250
 
252
251
def FastExponentiator(Q):