1

The original title was: 'Numpy array: 'data type not understood''. Turns out, the problem was my misunderstanding of Python as an interpreted language.

I have this very simple module 'rtm.py':

import numpy as np
def f():
    A=np.array([[1.0,0.5],[0.0,1.0]])

But when I run it in IPython:

import rtm
rtm.f()

I get this error:

      1 import numpy as np
      2 def f():
----> 3         np.array([[1.0,0.5],[0.0,1.0]])

TypeError: data type not understood

Which part in the documentation didn't I understand?

Thanks in advance!

4

1 回答 1

1

如果你想对解释器会话中可见的模块进行外部更改,你必须使用重新加载而不是导入:

蟒蛇2

import rtm
# some change in rtm.foo has been made
import rtm 
rtm.foo() # Old version of rtm.foo is called

reload(rtm) # You have to reload module ([docs][1])
rtm.foo() # Now you can call new version of rtm.foo

蟒蛇 3

...
from imp import reload
reload(rtm)
于 2013-09-14T15:43:23.480 回答