Skip to content

Commit

Permalink
Fix quad argument passing
Browse files Browse the repository at this point in the history
  • Loading branch information
rjfarmer committed Aug 30, 2023
1 parent a8f5a6f commit 80dc422
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gfort2py/fScalars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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:
Expand Down
15 changes: 15 additions & 0 deletions tests/complex_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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))

Expand All @@ -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:
Expand Down

0 comments on commit 80dc422

Please sign in to comment.