Passion/Python

[Bug Fix] Pycluster 의 Record 객체

sunshout 2009. 2. 25. 11:35


환경: Ubuntu 8.10
Python version : 2.5

Pycluster에 있는 예제를 실행해 보면 다음과 같은 에러가 발생한다.


Test.py (Language : python)
  1. from Pycluster import *
  2. handle = open("cyano.txt")
  3. record = read(handle)
  4. genetree = record.treecluster(method='s')
  5. genetree.scale()
  6. exptree = record.treecluster(dist='u', transpose=1)
  7. record.save("cyano_result", genetree, exptree)
  8.  


Error log (Language : python)
  1. Traceback (most recent call last):
  2.   File "test.py", line 7, in <module>
  3.     record.save("cyano_result", genetree, exptree)
  4.   File "/usr/lib/python2.5/site-packages/Pycluster/__init__.py", line 255, in save
  5.     (ngenes,nexps) = shape(self.data)
  6. NameError: global name 'shape' is not defined
  7.  

이는 shape의 객체가 어느 모듈에 있는지를 모르기 때문에 발생한다.
__init__.py 를 보면 import numpy만을 했기 때문에 객체를 call할 때는 모듈 네임을 붙여줘야 한다.

따라서 "/usr/lib/python2.5/site-packages/Pycluster/__init__.py" 파일의 255번째 줄을 수정하면 된다.

255번째 줄 (Language : python)
  1.     (ngenes,nexps) = numpy.shape(self.data)
  2.     if self.gorder==None: gorder = numpy.arange(ngenes)
  3.