开发者

Problem in loading web page when using polyval, polyfit using numpy

I am using django1.3. in CentOS5. My python version is 2.6 and using the numpy 1.6.1. I used in views.py a function which calculate the regression line.

A sample code:

from numpy import *
....
def test_func(request):
   n=50
   t=linspace(-5,5,n)
   #parameters
   a=0.8; b=-4
   x=polyval([a,b],t)
   #add some noise
   xn=x+randn(n)

   #Linear regressison -polyfit - polyfit can be used other orders polys
   (ar,br)=polyfit(t,xn,1)
   xr=polyval([ar开发者_开发问答,br],t)

 return ...

In the browser if I call the page, it cannot load. But it works fine in windows with the default development server which comes with the django.

Am I missing something?


You need to add the WSGIApplicationGroup directive to your httpd.conf file.

<Directory /www/django/apache>
    WSGIApplicationGroup %{GLOBAL}
    Order deny,allow
    Allow from all
</Directory>


I'm currently investigating a similar issue (Gentoo, Python 2.7, Numpy 1.6.0), and it would seem that only in wsgi, the following numpy code ends up blocking :

eps = np.finfo(float).eps

The help page for finfo says:

For developers of NumPy: do not instantiate this at the module level. The initial calculation of these parameters is expensive and negatively impacts import times. These objects are cached, so calling finfo() repeatedly inside your functions is not a problem.

Not sure what's going on here, but downgrading to Numpy 1.5.1 seems to have solved the issue.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜