diff --git a/gfort2py/fScalars.py b/gfort2py/fScalars.py index a676883..59d6dcd 100644 --- a/gfort2py/fScalars.py +++ b/gfort2py/fScalars.py @@ -27,7 +27,7 @@ def from_param(self, param): ) if self.cvalue is None: - self.cvalue = self.ctype() + self.cvalue = self.ctype()() for i in range(16): self.cvalue[i] = p[i] @@ -49,7 +49,7 @@ def value(self): if PYQ_IMPORTED: return pyq.qfloat.from_bytes(bytes(self.cvalue)) else: - raise NotImplementedError( + raise TypeError( f"Quad precision floats requires pyQuadp to be installed" ) elif self.kind == 8: diff --git a/tests/complex_test.py b/tests/complex_test.py index 028f35a..b4a680a 100644 --- a/tests/complex_test.py +++ b/tests/complex_test.py @@ -11,6 +11,13 @@ import pytest +try: + import pyquadp as pyq + + PYQ_IMPORTED = True +except ImportError: + PYQ_IMPORTED = False + SO = f"./tests/complex.{gf.lib_ext()}" MOD = "./tests/comp.mod" @@ -27,6 +34,7 @@ def test_a_const_cmplx(self): def test_a_const_cmplx_dp(self): self.assertEqual(x.const_cmplx_dp, complex(1.0, 1.0)) + @pytest.mark.skipif(not PYQ_IMPORTED, reason="pyquadp not available") def test_a_const_cmplx_qp(self): self.assertEqual(x.const_cmplx_qp, complex(1.0, 1.0)) @@ -40,6 +48,13 @@ def test_a_cmplx_dp(self): x.a_cmplx_dp = v self.assertEqual(x.a_cmplx_dp, v) + @pytest.mark.skipif(not PYQ_IMPORTED, reason="pyquadp not available") + def test_a_cmplx_qp(self): + v = complex(1.0, 1.0) + x.a_cmplx_qp = v + self.assertEqual(x.a_cmplx_qp, v) + + @pytest.mark.skipif(PYQ_IMPORTED, reason="tests when no pyqudp available") def test_a_cmplx_qp(self): v = complex(1.0, 1.0) with pytest.raises(TypeError) as cm: