precision.py :  » Business-Application » PDB2PQR » pdb2pqr-1.6 » contrib » numpy-1.1.0 » numpy » oldnumeric » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Business Application » PDB2PQR 
PDB2PQR » pdb2pqr 1.6 » contrib » numpy 1.1.0 » numpy » oldnumeric » precision.py
# Lifted from Precision.py.  This is for compatibility only.
#
#  The character strings are still for "new" NumPy
#   which is the only Incompatibility with Numeric

__all__ = ['Character', 'Complex', 'Float',
           'PrecisionError', 'PyObject', 'Int', 'UInt',
           'UnsignedInteger', 'string', 'typecodes', 'zeros']

from functions import zeros
import string   # for backwards compatibility

typecodes = {'Character':'c', 'Integer':'bhil', 'UnsignedInteger':'BHI', 'Float':'fd', 'Complex':'FD'}

def _get_precisions(typecodes):
    lst = []
    for t in typecodes:
        lst.append( (zeros( (1,), t ).itemsize*8, t) )
    return lst

def _fill_table(typecodes, table={}):
    for key, value in typecodes.items():
        table[key] = _get_precisions(value)
    return table

_code_table = _fill_table(typecodes)

class PrecisionError(Exception):
    pass

def _lookup(table, key, required_bits):
    lst = table[key]
    for bits, typecode in lst:
        if bits >= required_bits:
            return typecode
    raise PrecisionError, key+" of "+str(required_bits)+" bits not available on this system"

Character = 'c'

try:
    UnsignedInt8 = _lookup(_code_table, "UnsignedInteger", 8)
    UInt8 = UnsignedInt8
    __all__.extend(['UnsignedInt8', 'UInt8'])
except(PrecisionError):
    pass
try:
    UnsignedInt16 = _lookup(_code_table, "UnsignedInteger", 16)
    UInt16 = UnsignedInt16
    __all__.extend(['UnsignedInt16', 'UInt16'])
except(PrecisionError):
    pass
try:
    UnsignedInt32 = _lookup(_code_table, "UnsignedInteger", 32)
    UInt32 = UnsignedInt32
    __all__.extend(['UnsignedInt32', 'UInt32'])
except(PrecisionError):
    pass
try:
    UnsignedInt64 = _lookup(_code_table, "UnsignedInteger", 64)
    UInt64 = UnsignedInt64
    __all__.extend(['UnsignedInt64', 'UInt64'])
except(PrecisionError):
    pass
try:
    UnsignedInt128 = _lookup(_code_table, "UnsignedInteger", 128)
    UInt128 = UnsignedInt128
    __all__.extend(['UnsignedInt128', 'UInt128'])
except(PrecisionError):
    pass
UnsignedInteger = 'u'
UInt = UnsignedInteger

try:
    Int0 = _lookup(_code_table, 'Integer', 0)
    __all__.append('Int0')
except(PrecisionError):
    pass
try:
    Int8 = _lookup(_code_table, 'Integer', 8)
    __all__.append('Int8')
except(PrecisionError):
    pass
try:
    Int16 = _lookup(_code_table, 'Integer', 16)
    __all__.append('Int16')
except(PrecisionError):
    pass
try:
    Int32 = _lookup(_code_table, 'Integer', 32)
    __all__.append('Int32')
except(PrecisionError):
    pass
try:
    Int64 = _lookup(_code_table, 'Integer', 64)
    __all__.append('Int64')
except(PrecisionError):
    pass
try:
    Int128 = _lookup(_code_table, 'Integer', 128)
    __all__.append('Int128')
except(PrecisionError):
    pass
Int = 'l'

try:
    Float0 = _lookup(_code_table, 'Float', 0)
    __all__.append('Float0')
except(PrecisionError):
    pass
try:
    Float8 = _lookup(_code_table, 'Float', 8)
    __all__.append('Float8')
except(PrecisionError):
    pass
try:
    Float16 = _lookup(_code_table, 'Float', 16)
    __all__.append('Float16')
except(PrecisionError):
    pass
try:
    Float32 = _lookup(_code_table, 'Float', 32)
    __all__.append('Float32')
except(PrecisionError):
    pass
try:
    Float64 = _lookup(_code_table, 'Float', 64)
    __all__.append('Float64')
except(PrecisionError):
    pass
try:
    Float128 = _lookup(_code_table, 'Float', 128)
    __all__.append('Float128')
except(PrecisionError):
    pass
Float = 'd'

try:
    Complex0 = _lookup(_code_table, 'Complex', 0)
    __all__.append('Complex0')
except(PrecisionError):
    pass
try:
    Complex8 = _lookup(_code_table, 'Complex', 16)
    __all__.append('Complex8')
except(PrecisionError):
    pass
try:
    Complex16 = _lookup(_code_table, 'Complex', 32)
    __all__.append('Complex16')
except(PrecisionError):
    pass
try:
    Complex32 = _lookup(_code_table, 'Complex', 64)
    __all__.append('Complex32')
except(PrecisionError):
    pass
try:
    Complex64 = _lookup(_code_table, 'Complex', 128)
    __all__.append('Complex64')
except(PrecisionError):
    pass
try:
    Complex128 = _lookup(_code_table, 'Complex', 256)
    __all__.append('Complex128')
except(PrecisionError):
    pass
Complex = 'D'

PyObject = 'O'
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.