Пример #1
0
    def hash(self, funct, *args, **kwargs):
        """"Create a hash value"""
        pg.tic()
        functInfo = self.functInfo(funct)
        funcHash = strHash(functInfo)
        versionHash = strHash(pg.versionStr())
        codeHash = strHash(inspect.getsource(funct))

        argHash = 0
        for a in args:
            if isinstance(a, str):
                argHash = argHash ^ strHash(a)
            elif isinstance(a, list):
                for item in a:
                    if isinstance(item, str):
                        argHash = argHash ^ strHash(item)
                    else:
                        argHash = argHash ^ hash(item)
            else:
                argHash = argHash ^ hash(a)

        for k, v in kwargs.items():
            if isinstance(v, str):
                argHash = argHash ^ strHash(v)
            else:
                argHash = argHash ^ hash(v)

        pg.debug("Hashing took:", pg.dur(), "s")
        return funcHash ^ versionHash ^ codeHash ^ argHash
Пример #2
0
    def cache(self, funct, *args, **kwargs):
        """ Create a unique cache """
        hashVal = self.hash(funct, *args, **kwargs)

        cached = Cache(hashVal)
        cached.info['codeinfo'] = self.functInfo(funct)
        cached.info['version'] = pg.versionStr()
        cached.info['args'] = str(args)
        cached.info['kwargs'] = str(kwargs)

        return cached
Пример #3
0
    def hash(self, funct, *args, **kwargs):
        """"Create a hash value"""
        pg.tic()
        functInfo = self.functInfo(funct)
        funcHash = strHash(functInfo)
        versionHash = strHash(pg.versionStr())
        codeHash = strHash(inspect.getsource(funct))

        argHash = 0
        for a in args:
            argHash = argHash ^ valHash(a)

        for k, v in kwargs.items():
            argHash = argHash ^ valHash(k) ^ valHash(v)
            
        pg.debug("Hashing took:", pg.dur(), "s")
        return funcHash ^ versionHash ^ codeHash ^ argHash
Пример #4
0
*This next block should state any assumptions that you the writer are making. Present them in list form.*

Cite something :cite:`Zienkiewicz1977` or [Zienkiewicz1977]_

glossary ref :term:`numpy`

GIMLi api ref :gimliapi:`GIMLI::Cell`

pygimli ref ??????

'''

import pygimli as g

print((g.versionStr()))

"""
Last output

.. lastcout::

"""

"""
Invoking :term:`Matplotlib`.

Please see http://matplotlib.org/1.3.0/faq/usage_faq.html#general-concepts
"""

import matplotlib.pyplot as plt
Пример #5
0
*This next block should state any assumptions that you the writer are making. Present them in list form.*

Cite something :cite:`Zienkiewicz1977` or [Zienkiewicz1977]_

glossary ref :term:`numpy`

GIMLi api ref :gimliapi:`GIMLI::Cell`

pygimli ref ??????

'''

import pygimli as g

print((g.versionStr()))
"""
Last output

.. lastcout::

"""
"""
Invoking :term:`Matplotlib`.

Please see http://matplotlib.org/1.3.0/faq/usage_faq.html#general-concepts
"""

import matplotlib.pyplot as plt
plt.plot(1, 1, 'x')