mirror of
https://github.com/TREX-CoE/trexio.git
synced 2024-11-03 20:54:07 +01:00
adapt the tests to use basis_shell_num
This commit is contained in:
parent
9321213a21
commit
7459589701
@ -71,14 +71,14 @@ charges_np = np.array(charges, dtype=np.int32)
|
||||
# from the size of the list/array by SWIG using typemaps from numpy.i
|
||||
trexio.write_nucleus_charge(test_file, charges_np)
|
||||
|
||||
basis_num = 24
|
||||
basis_shell_num = 24
|
||||
# initialize arrays of nuclear indices as a list and convert it to numpy array
|
||||
indices = [i for i in range(basis_num)]
|
||||
indices = [i for i in range(basis_shell_num)]
|
||||
# type cast is important here because by default numpy transforms a list of integers into int64 array
|
||||
indices_np = np.array(indices, dtype=np.int64)
|
||||
|
||||
# first write basis_num because it is needed to check dimensions of basis_nucleus_index in TREXIO >= 2.0.0
|
||||
trexio.write_basis_num(test_file, basis_num)
|
||||
# first write basis_shell_num because it is needed to check dimensions of basis_nucleus_index in TREXIO >= 2.0.0
|
||||
trexio.write_basis_shell_num(test_file, basis_shell_num)
|
||||
|
||||
# function call below works with both lists and numpy arrays, dimension needed for memory-safety is derived
|
||||
# from the size of the list/array by SWIG using typemacs from numpy.i
|
||||
@ -164,20 +164,20 @@ except trexio.Error:
|
||||
print("Unsafe call to safe API: checked")
|
||||
|
||||
# safe call to read array of int values (nuclear indices)
|
||||
rindices_np_16 = trexio.read_basis_nucleus_index(test_file2, dim=basis_num, dtype=np.int16)
|
||||
rindices_np_16 = trexio.read_basis_nucleus_index(test_file2, dim=basis_shell_num, dtype=np.int16)
|
||||
assert rindices_np_16.dtype is np.dtype(np.int16)
|
||||
for i in range(basis_num):
|
||||
for i in range(basis_shell_num):
|
||||
assert rindices_np_16[i]==indices_np[i]
|
||||
|
||||
rindices_np_32 = trexio.read_basis_nucleus_index(test_file2, dim=basis_num, dtype=np.int32)
|
||||
rindices_np_32 = trexio.read_basis_nucleus_index(test_file2, dim=basis_shell_num, dtype=np.int32)
|
||||
assert rindices_np_32.dtype is np.dtype(np.int32)
|
||||
for i in range(basis_num):
|
||||
for i in range(basis_shell_num):
|
||||
assert rindices_np_32[i]==indices_np[i]
|
||||
|
||||
rindices_np_64 = trexio.read_basis_nucleus_index(test_file2)
|
||||
assert rindices_np_64.dtype is np.dtype(np.int64)
|
||||
assert rindices_np_64.size==basis_num
|
||||
for i in range(basis_num):
|
||||
assert rindices_np_64.size==basis_shell_num
|
||||
for i in range(basis_shell_num):
|
||||
assert rindices_np_64[i]==indices_np[i]
|
||||
|
||||
# read nuclear coordinates without providing optional argument dim
|
||||
|
@ -66,7 +66,7 @@ indices = [i for i in range(basis_num)]
|
||||
indices_np = np.array(indices, dtype=np.int32)
|
||||
|
||||
# first write basis_num because it is needed to check dimensions of basis_nucleus_index in TREXIO >= 2.0.0
|
||||
rc = trexio_write_basis_num(test_file, basis_num)
|
||||
rc = trexio_write_basis_shell_num(test_file, basis_num)
|
||||
assert rc==0
|
||||
|
||||
# function call below works with both lists and numpy arrays, dimension needed for memory-safety is derived
|
||||
@ -129,7 +129,7 @@ assert rc==23
|
||||
#for i in range(nucleus_num):
|
||||
# assert charges2[i]==charges[i]
|
||||
|
||||
result_basis = trexio_read_basis_num(test_file2)
|
||||
result_basis = trexio_read_basis_shell_num(test_file2)
|
||||
assert result[0]==0
|
||||
assert result[1]==basis_num
|
||||
|
||||
|
@ -25,7 +25,7 @@ static int test_write_dset (const char* file_name, const back_end_t backend) {
|
||||
assert (file != NULL);
|
||||
|
||||
// write numerical attribute in an empty file
|
||||
rc = trexio_write_basis_num(file, num);
|
||||
rc = trexio_write_basis_shell_num(file, num);
|
||||
assert (rc == TREXIO_SUCCESS);
|
||||
|
||||
// write numerical (integer) dataset in a file
|
||||
@ -91,7 +91,7 @@ static int test_read_dset (const char* file_name, const back_end_t backend) {
|
||||
assert (file != NULL);
|
||||
|
||||
// read numerical attribute from the file
|
||||
rc = trexio_read_basis_num(file, &num);
|
||||
rc = trexio_read_basis_shell_num(file, &num);
|
||||
assert (rc == TREXIO_SUCCESS);
|
||||
assert (num == 12);
|
||||
|
||||
|
@ -25,7 +25,7 @@ static int test_write_dset (const char* file_name, const back_end_t backend) {
|
||||
assert (file != NULL);
|
||||
|
||||
// write numerical attribute in an empty file
|
||||
rc = trexio_write_basis_num(file, num);
|
||||
rc = trexio_write_basis_shell_num(file, num);
|
||||
assert (rc == TREXIO_SUCCESS);
|
||||
|
||||
// write numerical (integer) dataset in a file
|
||||
@ -91,7 +91,7 @@ static int test_read_dset (const char* file_name, const back_end_t backend) {
|
||||
assert (file != NULL);
|
||||
|
||||
// read numerical attribute from the file
|
||||
rc = trexio_read_basis_num(file, &num);
|
||||
rc = trexio_read_basis_shell_num(file, &num);
|
||||
assert (rc == TREXIO_SUCCESS);
|
||||
assert (num == 12);
|
||||
|
||||
|
@ -44,7 +44,7 @@ subroutine test_write(file_name, back_end)
|
||||
|
||||
integer :: rc = 1
|
||||
|
||||
integer :: num, basis_num
|
||||
integer :: num, basis_shell_num
|
||||
|
||||
integer :: basis_nucleus_index(24)
|
||||
double precision :: charge(12)
|
||||
@ -70,7 +70,7 @@ subroutine test_write(file_name, back_end)
|
||||
0.00000000d0, 2.47304151d0 , 0.00000000d0 /), &
|
||||
shape(coord) )
|
||||
|
||||
basis_num = 24
|
||||
basis_shell_num = 24
|
||||
basis_nucleus_index = (/ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 /)
|
||||
|
||||
label = [character(len=8) :: 'C', 'Na','C', 'C 66', 'C','C', 'H 99', 'Ru', 'H', 'H', 'H', 'H' ]
|
||||
@ -105,7 +105,7 @@ subroutine test_write(file_name, back_end)
|
||||
deallocate(sym_str)
|
||||
call trexio_assert(rc, TREXIO_SUCCESS, 'SUCCESS WRITE POINT GROUP')
|
||||
|
||||
rc = trexio_write_basis_num(trex_file, basis_num)
|
||||
rc = trexio_write_basis_shell_num(trex_file, basis_shell_num)
|
||||
call trexio_assert(rc, TREXIO_SUCCESS, 'SUCCESS WRITE BASIS NUM')
|
||||
|
||||
rc = trexio_write_basis_nucleus_index(trex_file, basis_nucleus_index)
|
||||
@ -140,7 +140,7 @@ subroutine test_read(file_name, back_end)
|
||||
|
||||
integer :: i, j, k, ind, offset, flag
|
||||
integer :: rc = 1
|
||||
integer :: num, num_read, basis_num
|
||||
integer :: num, num_read, basis_shell_num
|
||||
|
||||
integer :: basis_nucleus_index(24)
|
||||
double precision :: charge(12)
|
||||
@ -155,7 +155,7 @@ subroutine test_read(file_name, back_end)
|
||||
character*(128) :: str
|
||||
|
||||
num = 12
|
||||
basis_num = 24
|
||||
basis_shell_num = 24
|
||||
|
||||
! ================= START OF TEST ===================== !
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user