pythonの開発環境を構築するのは結構めんどくさい。
プレーンなPython開発環境を構築するのはあっさりできるけど、モジュール(ライブラリ)を追加していくのがメンドクセー。
ScipyとかNumpyとかMatplotlibとかVpythonとか便利そうなモジュールを使おうとするとだいたいわけ分からんことになって解決するのに時間がかかる。
私は、そんなことを解決するのには興味が無いのでこういう作業は苦痛でしかない。
私のような人にはPython(x,y)とかEnthought社が出しているワンパッケージの開発環境がお勧めだ。
これらは、pythonインタプリタ、数値計算モジュール(scipy,numpy,matplotlib)がワンパッケージになっている。ついでにPython(x,y)はEclipse+pyDevがついてくる。
めんどくさがりにはうってつけだ。
2009年8月31日月曜日
pywinautoインストール
python2.6にpywinautoをインストールした。
pywinautoはwindowsのGUIアプリを自動操作するのに便利そうなモジュール。
依存関係にあるモジュールをインストールして、いよいよpywinautoのモジュールをインストールしますかねというところでつまずいた。
pywinautoのsetup.pyを使ってコマンドプロンプト上で
setup.py install
って打ってみたら、ctypesモジュールないとのエラー。
よく分からないがpyScripterにsetup.pyを突っ込んで引数にinstallを指定して動かしたらインストール成功。
pywinautoはwindowsのGUIアプリを自動操作するのに便利そうなモジュール。
依存関係にあるモジュールをインストールして、いよいよpywinautoのモジュールをインストールしますかねというところでつまずいた。
pywinautoのsetup.pyを使ってコマンドプロンプト上で
setup.py install
って打ってみたら、ctypesモジュールないとのエラー。
よく分からないがpyScripterにsetup.pyを突っ込んで引数にinstallを指定して動かしたらインストール成功。
2009年8月30日日曜日
python help()関数
例えば、
としてやれば、
Help on function quad in module scipy.integrate.quadpack:
quad(func, a, b, args=(), full_output=0, epsabs=1.4899999999999999e-008, epsrel=1.4899999999999999e-008, limit=50, points=None, weight=None, wvar=None, wopts=None, maxp1=50, limlst=50)
Compute a definite integral.
Description:
Integrate func from a to b (possibly infinite interval) using a technique
from the Fortran library QUADPACK. Run scipy.integrate.quad_explain()
for more information on the more esoteric inputs and outputs.
Inputs:
func -- a Python function or method to integrate.
a -- lower limit of integration (use -scipy.integrate.Inf for -infinity).
b -- upper limit of integration (use scipy.integrate.Inf for +infinity).
args -- extra arguments to pass to func.
full_output -- non-zero to return a dictionary of integration information.
If non-zero, warning messages are also suppressed and the
message is appended to the output tuple.
Outputs: (y, abserr, {infodict, message, explain})
y -- the integral of func from a to b.
abserr -- an estimate of the absolute error in the result.
infodict -- a dictionary containing additional information.
Run scipy.integrate.quad_explain() for more information.
message -- a convergence message.
explain -- appended only with 'cos' or 'sin' weighting and infinite
integration limits, it contains an explanation of the codes in
infodict['ierlst']
Additional Inputs:
epsabs -- absolute error tolerance.
epsrel -- relative error tolerance.
limit -- an upper bound on the number of subintervals used in the adaptive
algorithm.
points -- a sequence of break points in the bounded integration interval
where local difficulties of the integrand may occur (e.g.,
singularities, discontinuities). The sequence does not have
to be sorted.
**
** Run scipy.integrate.quad_explain() for more information
** on the following inputs
**
weight -- string indicating weighting function.
wvar -- variables for use with weighting functions.
limlst -- Upper bound on the number of cylces (>=3) for use with a sinusoidal
weighting and an infinite end-point.
wopts -- Optional input for reusing Chebyshev moments.
maxp1 -- An upper bound on the number of Chebyshev moments.
See also:
dblquad, tplquad - double and triple integrals
fixed_quad - fixed-order Gaussian quadrature
quadrature - adaptive Gaussian quadrature
odeint, ode - ODE integrators
simps, trapz, romb - integrators for sampled data
scipy.special - for coefficients and roots of orthogonal polynomials
None
とかって表示される。
print help(scipy.help.integrate.quad)
としてやれば、
Help on function quad in module scipy.integrate.quadpack:
quad(func, a, b, args=(), full_output=0, epsabs=1.4899999999999999e-008, epsrel=1.4899999999999999e-008, limit=50, points=None, weight=None, wvar=None, wopts=None, maxp1=50, limlst=50)
Compute a definite integral.
Description:
Integrate func from a to b (possibly infinite interval) using a technique
from the Fortran library QUADPACK. Run scipy.integrate.quad_explain()
for more information on the more esoteric inputs and outputs.
Inputs:
func -- a Python function or method to integrate.
a -- lower limit of integration (use -scipy.integrate.Inf for -infinity).
b -- upper limit of integration (use scipy.integrate.Inf for +infinity).
args -- extra arguments to pass to func.
full_output -- non-zero to return a dictionary of integration information.
If non-zero, warning messages are also suppressed and the
message is appended to the output tuple.
Outputs: (y, abserr, {infodict, message, explain})
y -- the integral of func from a to b.
abserr -- an estimate of the absolute error in the result.
infodict -- a dictionary containing additional information.
Run scipy.integrate.quad_explain() for more information.
message -- a convergence message.
explain -- appended only with 'cos' or 'sin' weighting and infinite
integration limits, it contains an explanation of the codes in
infodict['ierlst']
Additional Inputs:
epsabs -- absolute error tolerance.
epsrel -- relative error tolerance.
limit -- an upper bound on the number of subintervals used in the adaptive
algorithm.
points -- a sequence of break points in the bounded integration interval
where local difficulties of the integrand may occur (e.g.,
singularities, discontinuities). The sequence does not have
to be sorted.
**
** Run scipy.integrate.quad_explain() for more information
** on the following inputs
**
weight -- string indicating weighting function.
wvar -- variables for use with weighting functions.
limlst -- Upper bound on the number of cylces (>=3) for use with a sinusoidal
weighting and an infinite end-point.
wopts -- Optional input for reusing Chebyshev moments.
maxp1 -- An upper bound on the number of Chebyshev moments.
See also:
dblquad, tplquad - double and triple integrals
fixed_quad - fixed-order Gaussian quadrature
quadrature - adaptive Gaussian quadrature
odeint, ode - ODE integrators
simps, trapz, romb - integrators for sampled data
scipy.special - for coefficients and roots of orthogonal polynomials
None
とかって表示される。
python,scipyメモ
小数を含むリストを自動生成したい。
pythonの組み込み関数range()だと
みたいなことをすると、
step arguments must not be zero
エラーになる。step argumentsをzeroにしているつもりはないがダメらしい。内部的にintにキャストされる?
そこでscipyモジュールのarange()関数を使うとうまくいった。
みたいなことをやってもOKでした。不思議。
pythonの組み込み関数range()だと
range(0.0 , 10.0 , 0.1)
みたいなことをすると、
step arguments must not be zero
エラーになる。step argumentsをzeroにしているつもりはないがダメらしい。内部的にintにキャストされる?
そこでscipyモジュールのarange()関数を使うとうまくいった。
from scipy import *
from scipy import integrate
from pylab import *
start=0
end=2*pi
step=0.001
value = []
for x in arange(start,end,step):
value.append(integrate.quad(sin,start,x))
time=arange(start,end,step)
plot(time,value)
show()
みたいなことをやってもOKでした。不思議。
登録:
投稿 (Atom)