Permalink
Browse files

Merge pull request #2397 from RudolfWeeber/si_float

Scriptinterface: Avoid cast to float
  • Loading branch information...
fweik committed Dec 4, 2018
2 parents 563717b + daea72b commit 59f081bbb80ae870436262b2d3a356a791508565
@@ -161,7 +161,7 @@ cdef class PScriptInterface(object):
elif np.issubdtype(np.dtype(type(value)), np.signedinteger):
return make_variant[int](value)
elif np.issubdtype(np.dtype(type(value)), np.floating):
return make_variant[float](value)
return make_variant[double](value)
else:
raise TypeError("Unkown type for conversion to Variant")
@@ -94,6 +94,10 @@ class VariantTester : public ScriptInterfaceBase {
}
}
if (method == "mirror") {
return par.at("value");
}
throw std::runtime_error("Unknown method");
}
@@ -733,7 +733,7 @@ def test_zz_serialization(self):
res = reduce[0](reduce[1][0])
self.assertEqual(res.__class__.__name__, "CollisionDetection")
self.assertEqual(res.mode, "bind_centers")
self.assertAlmostEqual(res.distance, 0.11, delta=1E-9)
self.assertAlmostEqual(res.distance, 0.11, delta=1E-12)
self.assertEqual(res.bond_centers, self.H)
@@ -471,7 +471,7 @@ def test_hollowcone(self):
offset=0.,
eps=1.0,
sig=1.0,
r=1.134228603),
r=hollowcone_constraint.min_dist()),
places=9)
# Reset
@@ -46,6 +46,10 @@ def test_bool_return(self):
self.assertTrue(self.vt.call_method("true"))
self.assertFalse(self.vt.call_method("false"))
def test_mirror(self):
for v in 1.1, 0.6, 0.1232, 1, [1, 1.1], "blabla":
self.assertEqual(v, self.vt.call_method("mirror", value=v))
def test_default(self):
""" Check that a default constructed Variant translates to None.
"""

0 comments on commit 59f081b

Please sign in to comment.