Commit e85b3331 authored by Jérome Perrin's avatar Jérome Perrin

replace the use of scipy by rpy2

parent 44c31d9a
...@@ -33,7 +33,6 @@ import xlwt ...@@ -33,7 +33,6 @@ import xlwt
import xlrd import xlrd
from random import Random, expovariate, gammavariate, normalvariate from random import Random, expovariate, gammavariate, normalvariate
from SimPy.Simulation import now from SimPy.Simulation import now
import scipy.stats as stat
# =========================================================================== # ===========================================================================
# globals # globals
...@@ -257,7 +256,7 @@ def countQueueMetrics(argumentDict={}): ...@@ -257,7 +256,7 @@ def countQueueMetrics(argumentDict={}):
# ======================================================================= # =======================================================================
# Helper function to calculate the min, max and average values of a serie # Helper function to calculate the confidence intervals of a serie.
# ======================================================================= # =======================================================================
def getConfidenceIntervals(value_list): def getConfidenceIntervals(value_list):
from Globals import G from Globals import G
...@@ -266,8 +265,10 @@ def getConfidenceIntervals(value_list): ...@@ -266,8 +265,10 @@ def getConfidenceIntervals(value_list):
return { 'lb': value_list[0], return { 'lb': value_list[0],
'ub': value_list[0], 'ub': value_list[0],
'avg': value_list[0], } 'avg': value_list[0], }
bayes_mvs = stat.bayes_mvs(value_list, G.confidenceLevel) from dream.KnowledgeExtraction.ConfidenceIntervals import Intervals
return { 'lb': bayes_mvs[0][1][0], import numpy
'ub': bayes_mvs[0][1][1], lb, ub = Intervals().ConfidIntervals(value_list, G.confidenceLevel)
'avg': bayes_mvs[0][0], } return {'lb': lb,
'ub': ub,
'avg': numpy.mean(value_list) }
...@@ -30,25 +30,6 @@ import logging ...@@ -30,25 +30,6 @@ import logging
logger = logging.getLogger("dream.platform") logger = logging.getLogger("dream.platform")
try:
import scipy
except ImportError:
class scipy:
class stats:
@staticmethod
def bayes_mvs(*args, **kw):
warn("Scipy is missing, using fake implementation")
serie, confidence = args
import numpy
mean = numpy.mean(serie), (numpy.min(serie), numpy.max(serie))
var = 0, (0, 0)
std = 0, (0, 0)
return mean, var, std
import sys
sys.modules['scipy.stats'] = scipy.stats
sys.modules['scipy'] = scipy
logger.error("Scipy cannot be imported, using dummy implementation")
from SimPy.Simulation import activate, initialize, simulate, now, infinity from SimPy.Simulation import activate, initialize, simulate, now, infinity
from Globals import G from Globals import G
from Source import Source from Source import Source
......
...@@ -33,24 +33,6 @@ from warnings import warn ...@@ -33,24 +33,6 @@ from warnings import warn
import logging import logging
logger = logging.getLogger("dream.platform") logger = logging.getLogger("dream.platform")
try:
import scipy
except ImportError:
class scipy:
class stats:
@staticmethod
def bayes_mvs(*args, **kw):
warn("Scipy is missing, using fake implementation")
serie, confidence = args
import numpy
mean = numpy.mean(serie), (numpy.min(serie), numpy.max(serie))
var = 0, (0, 0)
std = 0, (0, 0)
return mean, var, std
import sys
sys.modules['scipy.stats'] = scipy.stats
sys.modules['scipy'] = scipy
logger.error("Scipy cannot be imported, using dummy implementation")
# By default numpy just prints on stderr when there's an error. We do not want # By default numpy just prints on stderr when there's an error. We do not want
# to hide errors. # to hide errors.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment