コード例 #1
0
ファイル: test_complexobject.py プロジェクト: griels/pypy-sc
    def test_pow(self):
        assert cobj._pow((0.0,2.0),(0.0,0.0)) == (1.0,0.0)
        assert cobj._pow((0.0,0.0),(2.0,0.0)) == (0.0,0.0)
        rr, ir = cobj._pow((0.0,1.0),(2.0,0.0))
        assert abs(-1.0 - rr) < EPS
        assert abs(0.0 - ir) < EPS

        assert cobj._powu((0.0,2.0),0) == (1.0,0.0)
        assert cobj._powu((0.0,0.0),2) == (0.0,0.0)
        assert cobj._powu((0.0,1.0),2) == (-1.0,0.0)
        assert cobj._powi((0.0,2.0),0) == (1.0,0.0)
        assert cobj._powi((0.0,0.0),2) == (0.0,0.0)
        assert cobj._powi((0.0,1.0),2) == (-1.0,0.0)
        c = cobj.W_ComplexObject(0.0,1.0)
        p = cobj.W_ComplexObject(2.0,0.0)
        r = cobj.pow__Complex_Complex_ANY(self.space,c,p,self.space.wrap(None))
        assert r.realval == -1.0
        assert r.imagval == 0.0
コード例 #2
0
 def _t_complex(r=0.0, i=0.0):
     c = cobj.W_ComplexObject(r, i)
     assert c.real == float(r) and c.imag == float(i)