# Path: opc/utils/prof.py
# def timefunc(f, reference=False):
#     global records
# 
#     records[f.__name__] = Record(f.__name__, reference)
# 
#     @wraps(f)
#     def f_timer(*args, **kwargs):
#         global active
# 
#         if not active:
#             return f(*args, **kwargs)
# 
#         start = time.time()
#         result = f(*args, **kwargs)
#         end = time.time()
# 
#         records[f.__name__].addTime(end-start)
# 
#         return result
# 
#     return f_timer
# 
# Path: opc/utils/wrapexception.py
# def wrapexception(func, logger=logging):
# 
#     def decorator(func):
# 
#         @wraps(func)
#         def wrapper(*args, **kwargs):
#             self = args[0]
#             try:
#                 r = func(*args, **kwargs)
#             except IndexError as e:
#                 if self.debug:
#                     logging.error("Bounds Error: "+str(e))
#                     raise e
# 
#         return wrapper
# 
#     return decorator


import numpy as np
import logging
from ..utils.prof import timefunc
from ..utils.wrapexception import wrapexception
        self.buf.buf[x, y] = color

    @timefunc
    def getPixel(self, x, y, wrap=False):
        """
        Retrieve the color tuple of the pixel from the specified location
        """
        if wrap:
            x = x % self.width
            y = y % self.height

        return self.buf.buf[x, y]

    @timefunc
    @wrapexception(logger)
    def drawPixel(self, x, y, color, alpha=None):
        """
        Set the pixel tuple at the specified location.  Perform no operation
        if the color value is None, or the address out of bounds
        """
        x, y = int(x), int(y)

        if alpha is None:
            self.buf.buf[x, y] = color
        else:
            a0 = alpha
            a1 = 1-alpha
            self.buf.buf[x, y] = np.asarray(color)*a0 + self.buf.buf[x, y]*a1

    @timefunc

# Path: opc/utils/prof.py
# def timefunc(f, reference=False):
#     global records
# 
#     records[f.__name__] = Record(f.__name__, reference)
# 
#     @wraps(f)
#     def f_timer(*args, **kwargs):
#         global active
# 
#         if not active:
#             return f(*args, **kwargs)
# 
#         start = time.time()
#         result = f(*args, **kwargs)
#         end = time.time()
# 
#         records[f.__name__].addTime(end-start)
# 
#         return result
# 
#     return f_timer
# 
# Path: opc/utils/wrapexception.py
# def wrapexception(func, logger=logging):
# 
#     def decorator(func):
# 
#         @wraps(func)
#         def wrapper(*args, **kwargs):
#             self = args[0]
#             try:
#                 r = func(*args, **kwargs)
#             except IndexError as e:
#                 if self.debug:
#                     logging.error("Bounds Error: "+str(e))
#                     raise e
# 
#         return wrapper
# 
#     return decorator


# Path: opc/matrix/pixel.py
import numpy as np
import logging
from ..utils.prof import timefunc
from ..utils.wrapexception import wrapexception

        self.buf.buf[x, y] = color

    @timefunc
    def getPixel(self, x, y, wrap=False):
        """
        Retrieve the color tuple of the pixel from the specified location
        """
        if wrap:
            x = x % self.width
            y = y % self.height

        return self.buf.buf[x, y]

    @timefunc
    @wrapexception(logger)
    def drawPixel(self, x, y, color, alpha=None):
        """
        Set the pixel tuple at the specified location.  Perform no operation
        if the color value is None, or the address out of bounds
        """
        x, y = int(x), int(y)

        if alpha is None:
            self.buf.buf[x, y] = color
        else:
            a0 = alpha
            a1 = 1-alpha
            self.buf.buf[x, y] = np.asarray(color)*a0 + self.buf.buf[x, y]*a1

    @timefunc

    @wrapexception(logger)