Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_numpy_apply_transform():
'''non-random transform'''
from molgrid import Transform, Quaternion, float3, MGrid2f, Grid2f
from math import sqrt
import numpy as np
q = Quaternion(sqrt(0.5),0,0,sqrt(0.5)) # //z 90
nr = Transform(q, float3(0,1,1), float3(2,0,-3))
#random
r = Transform(float3(0,1,1), 10.0, True)
coord_data = [ [0,0,0],
[1,0,0],
[0,1,0],
[0,0,1],
[-1,.5,3],
[1,1,1],
[0,1,1],
[.333,.75,-9] ]
coords = np.array(coord_data,np.float32)
coords2 = np.zeros((8,3),np.float32)
def test_random_transform():
from molgrid import Transform
molgrid.set_random_seed(0)
c1 = molgrid.float3(0,0,0);
c2 = molgrid.float3(0,0,1);
t1 = Transform(c1, 4.0, True)
t2 = Transform(c2, 4.0, True)
nrt1 = Transform (c1)
nrt2 = Transform (c2)
t = Transform()
molgrid.set_random_seed(0) # reset, should get same sample
t3 = Transform(c1, 4.0, True);
neqQ(t1.get_quaternion(),t2.get_quaternion());
neqQ(t1.get_quaternion(),nrt1.get_quaternion());
eqQ(t1.get_quaternion(),t3.get_quaternion());
def test_random_transform():
from molgrid import Transform
molgrid.set_random_seed(0)
c1 = molgrid.float3(0,0,0);
c2 = molgrid.float3(0,0,1);
t1 = Transform(c1, 4.0, True)
t2 = Transform(c2, 4.0, True)
nrt1 = Transform (c1)
nrt2 = Transform (c2)
t = Transform()
molgrid.set_random_seed(0) # reset, should get same sample
t3 = Transform(c1, 4.0, True);
neqQ(t1.get_quaternion(),t2.get_quaternion());
neqQ(t1.get_quaternion(),nrt1.get_quaternion());
eqQ(t1.get_quaternion(),t3.get_quaternion());
eqQ(nrt1.get_quaternion(),nrt2.get_quaternion());
def test_numpy_apply_transform():
'''non-random transform'''
from molgrid import Transform, Quaternion, float3, MGrid2f, Grid2f
from math import sqrt
import numpy as np
q = Quaternion(sqrt(0.5),0,0,sqrt(0.5)) # //z 90
nr = Transform(q, float3(0,1,1), float3(2,0,-3))
#random
r = Transform(float3(0,1,1), 10.0, True)
coord_data = [ [0,0,0],
[1,0,0],
[0,1,0],
[0,0,1],
[-1,.5,3],
[1,1,1],
[0,1,1],
[.333,.75,-9] ]
coords = np.array(coord_data,np.float32)
coords2 = np.zeros((8,3),np.float32)
#does nr perform as expected?
nr.forward(coords,coords2)
def test_apply_transform():
'''non-random transform'''
from molgrid import Transform, Quaternion, float3, MGrid2f, Grid2f
from math import sqrt
q = Quaternion(sqrt(0.5),0,0,sqrt(0.5)) # //z 90
nr = Transform(q, float3(0,1,1), float3(2,0,-3))
#random
r = Transform(float3(0,1,1), 10.0, True)
coord_data = [ [0,0,0],
[1,0,0],
[0,1,0],
[0,0,1],
[-1,.5,3],
[1,1,1],
[0,1,1],
[.333,.75,-9] ]
coords = MGrid2f(8,3)
coords2 = MGrid2f(8,3)
for i in range(8):
for j in range(3):
coords[i][j] = coord_data[i][j]
def test_apply_transform():
'''non-random transform'''
from molgrid import Transform, Quaternion, float3, MGrid2f, Grid2f
from math import sqrt
q = Quaternion(sqrt(0.5),0,0,sqrt(0.5)) # //z 90
nr = Transform(q, float3(0,1,1), float3(2,0,-3))
#random
r = Transform(float3(0,1,1), 10.0, True)
coord_data = [ [0,0,0],
[1,0,0],
[0,1,0],
[0,0,1],
[-1,.5,3],
[1,1,1],
[0,1,1],
[.333,.75,-9] ]
coords = MGrid2f(8,3)
coords2 = MGrid2f(8,3)