Skip to content

Commit

Permalink
update test code
Browse files Browse the repository at this point in the history
  • Loading branch information
hswoo369 committed Mar 21, 2021
1 parent 6326495 commit 03aa41d
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 48 deletions.
25 changes: 13 additions & 12 deletions test_code/test2.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@
cart=np.copy(snapshot.get_positions(wrap=True), order='C')
scale = np.copy(snapshot.get_scaled_positions(), order='C')

print('1. check if "atom_num" is total atom number')
print('atom num: %s\n'%atom_num)

# Check if Position information and cell parameter info extract correctly
print('2. check Cartesian coordination in "cart_p" (first 5, last 5 coordination)')
print('Cartesian coordination')
print( cart_p[0][0], cart_p[0][1], cart_p[0][2])
print(cart[0])

for i in range(5):
print 'cart: ', cart[i][0], cart[i][1], cart[i][2]
print 'cart_p: ', cart_p[i][0], cart_p[i][1], cart_p[i][2]
Expand All @@ -54,8 +52,8 @@
print 'cart: ', cart[i][0], cart[i][1], cart[i][2]
print 'cart_p: ', cart_p[i][0], cart_p[i][1], cart_p[i][2]

"""
print('\nFractional coordination')
print('\n3. check Fractional coordination in "cart_p" (first 5, last 5 coordination)')
print('Fractional coordination')
for i in range(5):
print 'scale: ', scale[i][0], scale[i][1], scale[i][2]
print 'scale_p: ', scale_p[i][0], scale_p[i][1], scale_p[i][2]
Expand All @@ -64,16 +62,19 @@
print 'scale: ', scale[i][0], scale[i][1], scale[i][2]
print 'scale_p: ', scale_p[i][0], scale_p[i][1], scale_p[i][2]

print('\nLattice parameter')
print('\n4. check lattice parameter')
print('Lattice parameter')
for i in range(3):
print(cell_p[i][0], cell_p[i][1], cell_p[i][2])

# Check if atom idx extract correctly and if saved in atom_i_p
print('\natom_i: %s'%atom_i)
print('\n5. check if atom_i_p value is equal atom_i')
print('atom_i: %s'%atom_i)
for i in range(atom_num):
if atom_i_p[i] != atom_i[i]:
print('%sth atom has different value'%i)

print('\ntype_num: %s'%type_num)
print('\ntype_idx: %s'%type_idx)
"""
print('\n6. check "type_num" has correct element types and atom number for each elements')
print('type_num: %s'%type_num)

print('\n7. check "type_idx" has correct atom index ')
print('type_idx: %s'%type_idx)
9 changes: 9 additions & 0 deletions test_code/test3.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,24 @@
"""
result = descriptor._init_result(type_num, structure_tags, structure_weights, idx, atom_i)

print("1. chcek if 'x', 'dx', 'da', 'params' is empty dictionary")
print 'x: ',result['x']
print 'dx: ', result['dx']
print 'da: ', result['da']
print 'params: ', result['params']

print("\n2. check if 'N' has correct element types and atom number for each elements")
print 'N: ', result['N']

print("\n3. check if 'tot_num' has total atom number")
print 'tot_num: ', result['tot_num']
print 'partition: ', result['partition']

print("\n4. check if 'struct_type', 'struct_weight' has correct tag, weight with correspond to idx (we set in previous setting # 3)")
print 'struct_type: ', result['struct_type']
print 'struct_weight: ', result['struct_weight']

print("\n5. check if 'atom_idx' set correctly")
prev=0
end=0
for elem in result['N']:
Expand Down
7 changes: 7 additions & 0 deletions test_code/test4.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,21 @@
jtem = 'Te'
cal_num, cal_atoms_p, x, dx, da, x_p, dx_p, da_p = descriptor._init_sf_variables(type_idx, jtem, symf_params_set, atom_num, mpi_range = None )

print('1. check if "jtem" atom number is correct')
print 'cal_num: ', cal_num

print('\n2. check if "jtem" atom idx is correct)')
print('cal_atom_p: '),
for i in range(cal_num):
print(cal_atoms_p[i]),
print

print("\n3. check if 'x', 'dx', 'da' is initialze to 0")
print 'x', x
print 'dx', dx
print 'da', da

print("\n4. check if 'x_p', 'dx_p', 'da_p' is initialize to 0")
for i in range(cal_num):
for j in range(symf_params_set[jtem]['num']):
if x_p[i][j] != 0 :
Expand Down
19 changes: 12 additions & 7 deletions test_code/test5.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,14 @@
""" Main test code
Test _set_result()
1. check if "jtem" atom number is correct
2. check if "jtem" atom idx is correct
3. check if 'x', 'dx', 'da' is initialze to 0
4. check if 'x_p', 'dx_p', 'da_p' is initialize to 0
1. check if 'N', 'tot_num', 'partition', 'struct_type', 'struct_weight' is identical to test3 results
2. check if partition_XX is correct
3. check if 'x', 'dx', 'da' has available values (didn't check if has identical values)
"""

result = descriptor._set_result(result, x, dx, da, type_num, jtem, symf_params_set, atom_num)
print(result.keys())

print("1. check if 'N', 'tot_num', 'partition', 'struct_type', 'struct_weight', 'atom_idx' are identical to test3 results")
print 'N: ', result['N']
print 'tot_num: ', result['tot_num']
print 'partition: ', result['partition']
Expand All @@ -70,5 +69,11 @@
end += result['N'][elem]
print 'result["N"][%s] atom_idx: '%elem, result['atom_idx'][prev:end], len(result['atom_idx'][prev:end])
prev += result['N'][elem]

print("\n2. check if partition_XX is correct")
print 'partition_%s: '%jtem, result['partition_%s'%jtem]
print(result['x'])

print("\n3. check if 'x', 'dx', 'da' has available values (didn't check if has identical values)")
print 'x: ', result['x']['Sb']
print'dx: ', result['dx']['Sb'][0]
print'da: ', result['da']['Sb'][0]
29 changes: 0 additions & 29 deletions test_code/test6.py

This file was deleted.

0 comments on commit 03aa41d

Please sign in to comment.