Ejemplo n.º 1
0
 def setUpClass(cls):
     from server.forecasting.statistical.build_extension import build_holtwinters_extension
     # compile and link holtwinters_fast module
     build_holtwinters_extension()
     #make them accessible everywhere
     global Cdouble_seasonal, Cmultiplicative
     from server.forecasting.statistical.holtwinters_fast import double_seasonal as Cdouble_seasonal
     from server.forecasting.statistical.holtwinters_fast import multiplicative as Cmultiplicative
Ejemplo n.º 2
0
import logging

from django.utils.timezone import utc

from server.settings import BASE_DIR, CYTHON_SUPPORT
   

""""try to import compiled holtwinters (double seasonal) extension by building it. 
if this fails, the standard holtwinters is used. """
fast_hw = False
if (CYTHON_SUPPORT):
    try:
        from server.forecasting.statistical.build_extension import build_holtwinters_extension
        try:
            t0 = time.time()
            build_holtwinters_extension() #compile and link
            #if function takes less than 8 seconds, the module was probably already built before
            fresh_build = time.time() - t0 > 8 
            from server.forecasting.statistical.holtwinters_fast import double_seasonal, multiplicative
            fast_hw = True
            if fresh_build:
                print "cython extension built and imported"
        except Exception as e:
            print "error while building. ", e
            print "check ecoControl.log"
    except Exception as e:
        print "cython probably not installed", e
    
if not fast_hw:
    if (CYTHON_SUPPORT):
        print "falling back to python holt-winters"
Ejemplo n.º 3
0
import calendar
from server.forecasting.statistical import StatisticalForecast
from server.settings import BASE_DIR, CYTHON_SUPPORT

import os
import time

""""try to import compiled holtwinters (double seasonal) extension by building it. 
if this fails, the standard holtwinters is used. """
fast_hw = False
if (CYTHON_SUPPORT):
    try:
        from server.forecasting.statistical.build_extension import build_holtwinters_extension
        try:
            t0 = time.time()
            build_holtwinters_extension() #compile and link
            #if function takes less than 10 seconds, the module was probably already built before
            fresh_build = time.time() - t0 > 10 
            from server.forecasting.statistical.holtwinters_fast import double_seasonal, multiplicative
            fast_hw = True
            if fresh_build:
                print "cython extension built and imported"
        except Exception as e:
            print "error while building. ", e
            print "check ecoControl.log"
    except Exception as e:
        print "cython probably not installed", e
    
if not fast_hw:
    if (CYTHON_SUPPORT):
        print "falling back to python holt-winters"