【发布时间】:2016-05-15 13:18:23
【问题描述】:
我有以下代码:
class SphericalRefraction(OpticalElement):
def __init__(self, r0, normal, curvature, n, h):
self._r0 = r0
self._normal = normal/npl.norm(normal)
self._curvature = curvature
self._n = n
self._aperture = h
def OutputPlane(SphericalRefraction):
def __init__(self, r0, normal, h=15):
SphericalRefraction.__init__(self, r0=r0, normal=normal, curvature=0, n=1, h=h)
但是当我在 main 中构造一个类 OutputPlane 时:
screen = r.OutputPlane(np.array([0,0,f]),np.array([0,0,1]), 5)
我有以下错误:
TypeError: OutputPlane() takes exactly 1 argument (3 given)
我做错了什么?我应该怎么做才能从 SphericalRefraction 继承 OutputPlane?
【问题讨论】:
-
r.OutputPlane(..中的r是什么? -
您没有显示足够的代码。
-
你的
OutputPlane是一个函数(用def声明)。我猜你想使用class?
标签: python class oop inheritance typeerror